diff --git a/configs/dumps/search-config-v2.json b/configs/dumps/search-config-v2.json new file mode 100644 index 000000000..2596da9ac --- /dev/null +++ b/configs/dumps/search-config-v2.json @@ -0,0 +1,20 @@ +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this file, +// You can obtain one at http://mozilla.org/MPL/2.0/. +{ + "remove": { + "identifiers": [ + // Firefox adds Perplexity by default, we don't want it as + // its not very privacy focused. + "perplexity", + + // These are not search engines, Firefox adds them by default + // but we don't want them. + "wikipedia", + "wikipedia-*", + "ebay", + "ebay-*" + ] + }, + "timestamp": 1765455207275 +} diff --git a/package.json b/package.json index 355f9be11..963e0b0b2 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,8 @@ "build": "surfer build", "build:ui": "surfer build --ui", "start": "cd engine && python3 ./mach run --noprofile", - "import": "npm run ffprefs && surfer import", + "import": "npm run ffprefs && npm run import:dumps && surfer import", + "import:dumps": "python3 scripts/update_service_dumps.py", "export": "surfer export", "init": "npm run download && npm run import && npm run bootstrap", "download": "surfer download", diff --git a/prefs/firefox/ai.yaml b/prefs/firefox/ai.yaml index e54bb0d38..a89b6a439 100644 --- a/prefs/firefox/ai.yaml +++ b/prefs/firefox/ai.yaml @@ -20,3 +20,6 @@ - name: browser.ml.chat.menu value: false + +- name: browser.ml.linkPreview.enabled + value: false diff --git a/scripts/json_with_comments.py b/scripts/json_with_comments.py new file mode 100644 index 000000000..18eab24fc --- /dev/null +++ b/scripts/json_with_comments.py @@ -0,0 +1,14 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +import json + + +class JSONWithCommentsDecoder(json.JSONDecoder): + def __init__(self, **kw): + super().__init__(**kw) + + def decode(self, s: str) -> Any: + s = '\n'.join(l for l in s.split('\n') if not l.lstrip(' ').startswith('//')) + return super().decode(s) diff --git a/scripts/run_tests.py b/scripts/run_tests.py index 90a7995a8..5fdbd6d53 100644 --- a/scripts/run_tests.py +++ b/scripts/run_tests.py @@ -7,6 +7,7 @@ import sys import json from pathlib import Path from typing import Any +from json_with_comments import JSONWithCommentsDecoder IGNORE_PREFS_FILE_IN = os.path.join( 'src', 'zen', 'tests', 'ignorePrefs.json' @@ -16,15 +17,6 @@ IGNORE_PREFS_FILE_OUT = os.path.join( ) -class JSONWithCommentsDecoder(json.JSONDecoder): - def __init__(self, **kw): - super().__init__(**kw) - - def decode(self, s: str) -> Any: - s = '\n'.join(l for l in s.split('\n') if not l.lstrip(' ').startswith('//')) - return super().decode(s) - - def copy_ignore_prefs(): print("Copying ignorePrefs.json from src/zen/tests to engine/testing/mochitest...") # if there are prefs that dont exist on output file, copy them from input file diff --git a/scripts/update_service_dumps.py b/scripts/update_service_dumps.py new file mode 100644 index 000000000..63ef85c34 --- /dev/null +++ b/scripts/update_service_dumps.py @@ -0,0 +1,63 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +import os +import json +from json_with_comments import JSONWithCommentsDecoder + +DUMPS_FOLDER = os.path.join( + 'configs', 'dumps' +) +ENGINE_DUMPS_FOLDER = os.path.join( + 'engine', 'services', 'settings', 'dumps', 'main' +) + + +def merge_dumps(original, updates): + """Filters entries from the original dump, removing those whose identifiers are specified in the updates removal list.""" + remove_ids = updates.get('remove', {"identifiers": []}).get('identifiers', []) + + # Filter out entries in original that are in remove_ids. + #  We may find example-* patterns, so we need to handle that as well. + merged_data = [ + entry for entry in original.get('data', []) + if not any( + entry.get('identifier', '') == rid or + (rid.endswith('*') and entry.get('identifier', '').startswith(rid[:-1])) + for rid in remove_ids + ) + ] + + return { + 'data': merged_data, + **{k: v for k, v in original.items() if k != 'data'}, + 'timestamp': updates.get('timestamp', original.get('timestamp')) + } + + +def main(): + for filename in os.listdir(DUMPS_FOLDER): + if filename.endswith('.json'): + #  parse json with comments + with open(os.path.join(DUMPS_FOLDER, filename), 'r') as f: + data = json.load(f, cls=JSONWithCommentsDecoder) + original_path = os.path.join(ENGINE_DUMPS_FOLDER, filename) + if os.path.exists(original_path): + with open(original_path, 'r', encoding='utf-8') as f: + original_content = f.read() + original_content = '\n'.join( + line for line in original_content.split('\n') if not line.lstrip(' ').startswith('//') + ) + original_data = json.loads(original_content) + merged_data = merge_dumps(original_data, data) + with open(original_path, 'w', encoding='utf-8') as f: + json.dump(merged_data, f, indent=2, ensure_ascii=False) + print(f"Updated dump: {filename}") + else: + print(f"Original dump file not found: {original_path}") + exit(1) + + +if __name__ == "__main__": + main()