diff --git a/.vscode/settings.json b/.vscode/settings.json index 095f5a2..ef75b7c 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,4 +1,7 @@ { "files.autoSave": "afterDelay", - "files.autoSaveDelay": 120000 -} + "files.autoSaveDelay": 120000, + "files.associations": { + "*.manifest.append": "chrome-manifest" + } +} \ No newline at end of file diff --git a/.webpack/webpack.config.cjs b/.webpack/webpack.config.cjs index 3f3969a..81700f9 100644 --- a/.webpack/webpack.config.cjs +++ b/.webpack/webpack.config.cjs @@ -5,6 +5,7 @@ const HtmlWebpackPlugin = require('html-webpack-plugin') const MiniCssExtractPlugin = require('mini-css-extract-plugin') const WebpackLicensePlugin = require('webpack-license-plugin') const preprocess = require('svelte-preprocess') +const CopyWebpackPlugin = require('copy-webpack-plugin') const HTML_TEMPLATE_FILE = './src/content/index.html' @@ -150,6 +151,14 @@ const sharedSettings = (contentFiles, dev) => { unacceptableLicenseTest: (licenseIdentifier) => ['GPL', 'AGPL', 'LGPL', 'NGPL'].includes(licenseIdentifier), }), + new CopyWebpackPlugin({ + patterns: [ + { + from: 'static', + to: getDistFile('browser_content'), + }, + ], + }), ], experiments: { diff --git a/scripts/lib/files.ts b/scripts/lib/files.ts new file mode 100644 index 0000000..f96db58 --- /dev/null +++ b/scripts/lib/files.ts @@ -0,0 +1,27 @@ +import { readFile, writeFile } from 'fs/promises' + +import { getArtifactFile } from './constants.js' + +export const CHANGES: { file: string; append?: string | string[] }[] = [ + { + file: 'chrome/chrome.manifest', + append: + 'resource search-extensions browser/content/browser/search-extensions/ contentaccessible=yes', + }, +] + +export async function setupFiles() { + for (const change of CHANGES) { + const file = getArtifactFile(change.file) + let contents = await readFile(file, 'utf-8') + + if (change.append) { + const append = Array.isArray(change.append) + ? change.append + : [change.append] + contents += '\n' + append.join('\n') + } + + await writeFile(file, contents) + } +} diff --git a/scripts/setup.ts b/scripts/setup.ts index b33f368..b9642f8 100644 --- a/scripts/setup.ts +++ b/scripts/setup.ts @@ -13,7 +13,6 @@ import { existsSync } from 'fs' import { mkdir, rm, symlink } from 'fs/promises' -import { join } from 'node:path' import { execa } from 'execa' import { downloadReleaseAsset, getLatestRelease } from './lib/releases.js' @@ -25,6 +24,7 @@ import { getSrcFile, } from './lib/constants.js' import { linkFolder } from './lib/linker.js' +import { setupFiles } from './lib/files.js' const OWNER = 'pulse-browser' const REPO = 'experiment-runtime' @@ -84,6 +84,9 @@ await symlink(prefFileSrc, prefFile) await linkFolder('modules') await linkFolder('actors') +info('Setting up files...') +await setupFiles() + info('') info('You are all set up!') info(' To start webpack, run `pnpm dev`') diff --git a/src/content/browser/lib/xul/search.ts b/src/content/browser/lib/xul/search.ts new file mode 100644 index 0000000..ce1adfc --- /dev/null +++ b/src/content/browser/lib/xul/search.ts @@ -0,0 +1,4 @@ + +export async function getSearch() { + if (Services.search.) +} \ No newline at end of file diff --git a/static/search-extensions/README.md b/static/search-extensions/README.md new file mode 100644 index 0000000..6427196 --- /dev/null +++ b/static/search-extensions/README.md @@ -0,0 +1,12 @@ +# Search engine files + +## From Mozilla + +The following files are copied (with small modifications) from gecko-dev. + +- [ddg](./ddg/) - [source](https://searchfox.org/mozilla-central/source/browser/components/search/extensions/ddg/) +- [google](./google/) - [source](https://searchfox.org/mozilla-central/source/browser/components/search/extensions/google/) + +## License + +Note: Even though these files do not include headers, they are all under MPL-2.0 diff --git a/static/search-extensions/ddg/favicon.ico b/static/search-extensions/ddg/favicon.ico new file mode 100644 index 0000000..3ad2082 Binary files /dev/null and b/static/search-extensions/ddg/favicon.ico differ diff --git a/static/search-extensions/ddg/manifest.json b/static/search-extensions/ddg/manifest.json new file mode 100644 index 0000000..e339609 --- /dev/null +++ b/static/search-extensions/ddg/manifest.json @@ -0,0 +1,27 @@ +{ + "name": "DuckDuckGo", + "description": "Search with DuckDuckGo", + "manifest_version": 2, + "version": "1.4", + "browser_specific_settings": { + "gecko": { + "id": "ddg@search.fushra.com" + } + }, + "hidden": true, + "icons": { + "16": "favicon.ico" + }, + "web_accessible_resources": ["favicon.ico"], + "chrome_settings_overrides": { + "search_provider": { + "keyword": ["@duckduckgo", "@ddg"], + "name": "DuckDuckGo", + "search_url": "https://duckduckgo.com/", + "search_form": "https://duckduckgo.com/", + "search_url_get_params": "t=ffab&q={searchTerms}", + "suggest_url": "https://ac.duckduckgo.com/ac/", + "suggest_url_get_params": "q={searchTerms}&type=list" + } + } +} diff --git a/static/search-extensions/google/favicon.ico b/static/search-extensions/google/favicon.ico new file mode 100644 index 0000000..82339b3 Binary files /dev/null and b/static/search-extensions/google/favicon.ico differ diff --git a/static/search-extensions/google/manifest.json b/static/search-extensions/google/manifest.json new file mode 100644 index 0000000..1d1b598 --- /dev/null +++ b/static/search-extensions/google/manifest.json @@ -0,0 +1,34 @@ +{ + "name": "Google", + "description": "Search with Google", + "manifest_version": 2, + "version": "1.4", + "browser_specific_settings": { + "gecko": { + "id": "google@search.fushra.com" + } + }, + "hidden": true, + "default_locale": "en", + "icons": { + "16": "favicon.ico" + }, + "web_accessible_resources": ["favicon.ico"], + "chrome_settings_overrides": { + "search_provider": { + "keyword": "@google", + "name": "Google", + "search_url": "https://www.google.com/search", + "search_form": "https://www.google.com/search", + "suggest_url": "https://www.google.com/complete/search?client=fushra&q={searchTerms}", + "params": [ + { + "name": "channel", + "condition": "pref", + "pref": "google_channel_row" + } + ], + "search_url_get_params": "client=fushra&q={searchTerms}" + } + } +}