Skip to content

Commit

Permalink
🚧 Create search extension files
Browse files Browse the repository at this point in the history
  • Loading branch information
trickypr committed Nov 11, 2023
1 parent 28c0bda commit b59ccd1
Show file tree
Hide file tree
Showing 10 changed files with 122 additions and 3 deletions.
7 changes: 5 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"files.autoSave": "afterDelay",
"files.autoSaveDelay": 120000
}
"files.autoSaveDelay": 120000,
"files.associations": {
"*.manifest.append": "chrome-manifest"
}
}
9 changes: 9 additions & 0 deletions .webpack/webpack.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down Expand Up @@ -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: {
Expand Down
27 changes: 27 additions & 0 deletions scripts/lib/files.ts
Original file line number Diff line number Diff line change
@@ -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)
}
}
5 changes: 4 additions & 1 deletion scripts/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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'
Expand Down Expand Up @@ -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`')
Expand Down
4 changes: 4 additions & 0 deletions src/content/browser/lib/xul/search.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

export async function getSearch() {
if (Services.search.)
}
12 changes: 12 additions & 0 deletions static/search-extensions/README.md
Original file line number Diff line number Diff line change
@@ -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
Binary file added static/search-extensions/ddg/favicon.ico
Binary file not shown.
27 changes: 27 additions & 0 deletions static/search-extensions/ddg/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "DuckDuckGo",
"description": "Search with DuckDuckGo",
"manifest_version": 2,
"version": "1.4",
"browser_specific_settings": {
"gecko": {
"id": "[email protected]"
}
},
"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"
}
}
}
Binary file added static/search-extensions/google/favicon.ico
Binary file not shown.
34 changes: 34 additions & 0 deletions static/search-extensions/google/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"name": "Google",
"description": "Search with Google",
"manifest_version": 2,
"version": "1.4",
"browser_specific_settings": {
"gecko": {
"id": "[email protected]"
}
},
"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}"
}
}
}

0 comments on commit b59ccd1

Please sign in to comment.