You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
firefox/SOURCES/use_yandex_search_as_defaul...

45 lines
1.0 KiB

import json
import sys
import datetime
YANDEX_SECTION = json.loads('''
{
"appliesTo": [
{
"default": "yes",
"included": {
"everywhere": true
}
}
],
"id": "a0e7f96a-14e0-4d56-9f54-e0c7e49fd306",
"last_modified": 1679065511545,
"schema": 1639069022290,
"webExtension": {
"id": "yandex@search.mozilla.org"
}
}
''')
search_config = None
with open(sys.argv[1]) as f:
search_config = json.load(f)
inserted = False
for engine in search_config["data"]:
if engine["webExtension"]["id"] == "yandex@search.mozilla.org":
inserted = True
engine = YANDEX_SECTION
else:
for applies in engine["appliesTo"]:
if "default" in applies and applies["default"] == "yes":
applies["default"] = "no"
if not inserted:
search_config["data"] = [YANDEX_SECTION] + search_config["data"]
search_config["timestamp"] = int( datetime.datetime.now().timestamp() ) * 1000
with open(sys.argv[1], 'w') as f:
json.dump(search_config, f, indent=2)