parent
51abb2b84d
commit
b16b1359a7
@ -0,0 +1,53 @@
|
|||||||
|
From 70366cd339ac14a32e5b0cdab05a25166ec169a3 Mon Sep 17 00:00:00 2001
|
||||||
|
From: tigro <tigro@msvsphere-os.ru>
|
||||||
|
Date: Fri, 1 Nov 2024 14:58:02 +0300
|
||||||
|
Subject: [PATCH] Return Yandex engine support
|
||||||
|
|
||||||
|
---
|
||||||
|
services/settings/dumps/main/moz.build | 2 ++
|
||||||
|
.../components/backgroundtasks/BackgroundTask_message.sys.mjs | 2 +-
|
||||||
|
toolkit/modules/AppConstants.sys.mjs | 2 +-
|
||||||
|
3 files changed, 4 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/services/settings/dumps/main/moz.build b/services/settings/dumps/main/moz.build
|
||||||
|
index 5b1e881..6a89f0d 100644
|
||||||
|
--- a/services/settings/dumps/main/moz.build
|
||||||
|
+++ b/services/settings/dumps/main/moz.build
|
||||||
|
@@ -62,6 +62,8 @@ if CONFIG["MOZ_BUILD_APP"] == "browser":
|
||||||
|
"search-config-icons/2e835b0e-9709-d1bb-9725-87f59f3445ca.meta.json",
|
||||||
|
"search-config-icons/32d26d19-aeb0-5c01-32e8-f8970be9246f",
|
||||||
|
"search-config-icons/32d26d19-aeb0-5c01-32e8-f8970be9246f.meta.json",
|
||||||
|
+ "search-config-icons/32dc5c21-98c7-4355-8603-398c9f5eec49",
|
||||||
|
+ "search-config-icons/32dc5c21-98c7-4355-8603-398c9f5eec49.meta.json",
|
||||||
|
"search-config-icons/39979158-80cf-4f0c-8bd6-9220eb09e751",
|
||||||
|
"search-config-icons/39979158-80cf-4f0c-8bd6-9220eb09e751.meta.json",
|
||||||
|
"search-config-icons/47da97b5-600f-c450-fd15-a52bb2169c11",
|
||||||
|
diff --git a/toolkit/components/backgroundtasks/BackgroundTask_message.sys.mjs b/toolkit/components/backgroundtasks/BackgroundTask_message.sys.mjs
|
||||||
|
index aafe4a6..6ef1c45 100644
|
||||||
|
--- a/toolkit/components/backgroundtasks/BackgroundTask_message.sys.mjs
|
||||||
|
+++ b/toolkit/components/backgroundtasks/BackgroundTask_message.sys.mjs
|
||||||
|
@@ -71,7 +71,7 @@ ChromeUtils.defineESModuleGetters(lazy, {
|
||||||
|
Utils: "resource://services-settings/Utils.sys.mjs",
|
||||||
|
});
|
||||||
|
|
||||||
|
-const SERVER_STAGE = "https://firefox.settings.services.allizom.org/v1";
|
||||||
|
+const SERVER_STAGE = "https://127.0.0.1";
|
||||||
|
|
||||||
|
// Default profile targeting snapshot.
|
||||||
|
let defaultProfileTargetingSnapshot = {};
|
||||||
|
diff --git a/toolkit/modules/AppConstants.sys.mjs b/toolkit/modules/AppConstants.sys.mjs
|
||||||
|
index 4678835..4913eca 100644
|
||||||
|
--- a/toolkit/modules/AppConstants.sys.mjs
|
||||||
|
+++ b/toolkit/modules/AppConstants.sys.mjs
|
||||||
|
@@ -421,7 +421,7 @@ export var AppConstants = Object.freeze({
|
||||||
|
#ifdef MOZ_THUNDERBIRD
|
||||||
|
"https://thunderbird-settings.thunderbird.net/v1",
|
||||||
|
#else
|
||||||
|
- "https://firefox.settings.services.mozilla.com/v1",
|
||||||
|
+ "https://127.0.0.1",
|
||||||
|
#endif
|
||||||
|
|
||||||
|
REMOTE_SETTINGS_VERIFY_SIGNATURE:
|
||||||
|
--
|
||||||
|
2.47.0
|
||||||
|
|
@ -1,44 +1,171 @@
|
|||||||
|
import datetime
|
||||||
import json
|
import json
|
||||||
|
import os
|
||||||
|
import shutil
|
||||||
import sys
|
import sys
|
||||||
import datetime
|
|
||||||
|
|
||||||
YANDEX_SECTION = json.loads('''
|
YANDEX_SEARCH_ENGINE_SECTION = json.loads('''
|
||||||
{
|
{
|
||||||
"appliesTo": [
|
"base": {
|
||||||
|
"aliases": [
|
||||||
|
"yandex"
|
||||||
|
],
|
||||||
|
"classification": "general",
|
||||||
|
"name": "Yandex",
|
||||||
|
"partnerCode": "",
|
||||||
|
"urls": {
|
||||||
|
"search": {
|
||||||
|
"base": "https://yandex.ru/search/",
|
||||||
|
"params": [
|
||||||
|
{
|
||||||
|
"name": "clid",
|
||||||
|
"value": "{partnerCode}"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"searchTermParamName": "text"
|
||||||
|
},
|
||||||
|
"suggestions": {
|
||||||
|
"base": "https://suggest.yandex.ru/suggest-ff.cgi",
|
||||||
|
"params": [
|
||||||
|
{
|
||||||
|
"name": "clid",
|
||||||
|
"value": "{partnerCode}"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"searchTermParamName": "part"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"id": "",
|
||||||
|
"identifier": "yandex",
|
||||||
|
"last_modified": 0,
|
||||||
|
"recordType": "engine",
|
||||||
|
"schema": 0,
|
||||||
|
"variants": [
|
||||||
{
|
{
|
||||||
"default": "yes",
|
"environment": {
|
||||||
"included": {
|
"allRegionsAndLocales": true
|
||||||
"everywhere": true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
''')
|
||||||
|
|
||||||
|
YANDEX_ICON_SECTION = json.loads('''
|
||||||
|
{
|
||||||
|
"schema": 0,
|
||||||
|
"imageSize": 32,
|
||||||
|
"attachment": {
|
||||||
|
"hash": "6bb91f1d74389b18bce6e71772e4c5573648c1a4823338193f700afdf8216be5",
|
||||||
|
"size": 5750,
|
||||||
|
"filename": "yandex-32-firefox.png",
|
||||||
|
"location": "main-workspace/search-config-icons/1f0aef96-9d62-4519-906d-379b710a80e8.ico",
|
||||||
|
"mimetype": "image/x-icon"
|
||||||
|
},
|
||||||
|
"engineIdentifiers": [
|
||||||
|
"yandex"
|
||||||
],
|
],
|
||||||
"id": "a0e7f96a-14e0-4d56-9f54-e0c7e49fd306",
|
"filter_expression": "env.appinfo.ID == \\"{ec8030f7-c20a-464f-9b0e-13a3a9e97384}\\"",
|
||||||
"last_modified": 1679065511545,
|
"id": "",
|
||||||
"schema": 1639069022290,
|
"last_modified": 0
|
||||||
"webExtension": {
|
|
||||||
"id": "yandex@search.mozilla.org"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
''')
|
''')
|
||||||
|
|
||||||
|
YANDEX_SEARCH_ENGINE_ID = "403a24ac-3e95-4581-88e4-a479eb4ce558"
|
||||||
|
YANDEX_ICON_ID = "32dc5c21-98c7-4355-8603-398c9f5eec49"
|
||||||
|
|
||||||
|
# ROSA Linux
|
||||||
|
PARTNER_CLID = "2800424"
|
||||||
|
|
||||||
|
SEARCH_CONFIG_RELATIVE_PATH = "services/settings/dumps/main/search-config-v2.json"
|
||||||
|
SEARCH_CONFIG_ICONS_RELATIVE_PATH = "services/settings/dumps/main/search-config-icons.json"
|
||||||
|
YANDEX_ICON_META_RELATIVE_DIR = "services/settings/dumps/main/search-config-icons/"
|
||||||
|
|
||||||
|
search_config_path = SEARCH_CONFIG_RELATIVE_PATH
|
||||||
|
if not os.path.isfile(search_config_path):
|
||||||
|
print(search_config_path, "not found")
|
||||||
|
exit(1)
|
||||||
|
|
||||||
|
search_config_icons_path = SEARCH_CONFIG_ICONS_RELATIVE_PATH
|
||||||
|
if not os.path.isfile(search_config_icons_path):
|
||||||
|
print(search_config_icons_path, "not found")
|
||||||
|
exit(2)
|
||||||
|
|
||||||
|
yandex_icon_meta_path = os.path.join(YANDEX_ICON_META_RELATIVE_DIR, YANDEX_ICON_ID + ".meta.json")
|
||||||
|
|
||||||
|
YANDEX_SEARCH_ENGINE_SECTION["id"] = YANDEX_SEARCH_ENGINE_ID
|
||||||
|
YANDEX_SEARCH_ENGINE_SECTION["base"]["partnerCode"] = PARTNER_CLID
|
||||||
|
|
||||||
|
timestamp = int( datetime.datetime.now().timestamp() ) * 1000
|
||||||
|
YANDEX_SEARCH_ENGINE_SECTION["last_modified"] = timestamp
|
||||||
|
YANDEX_SEARCH_ENGINE_SECTION["schema"] = timestamp
|
||||||
|
|
||||||
|
YANDEX_ICON_SECTION["id"] = YANDEX_ICON_ID
|
||||||
|
YANDEX_ICON_SECTION["last_modified"] = timestamp
|
||||||
|
YANDEX_ICON_SECTION["schema"] = timestamp
|
||||||
|
|
||||||
search_config = None
|
search_config = None
|
||||||
with open(sys.argv[1]) as f:
|
with open(search_config_path) as f:
|
||||||
search_config = json.load(f)
|
search_config = json.load(f)
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
yandex_search_engine_inserted = False
|
||||||
|
for i, engine in enumerate(search_config["data"]):
|
||||||
|
if "globalDefault" in engine:
|
||||||
|
engine["globalDefault"] = "yandex"
|
||||||
|
engine["last_modified"] = timestamp
|
||||||
|
engine["schema"] = timestamp
|
||||||
|
elif "orders" in engine:
|
||||||
|
for order in engine["orders"]:
|
||||||
|
if "order" in order:
|
||||||
|
yandex_inserted = False
|
||||||
|
for s in order["order"]:
|
||||||
|
if s == "yandex":
|
||||||
|
yandex_inserted = True
|
||||||
|
if not yandex_inserted:
|
||||||
|
order["order"] = ["yandex"] + order["order"]
|
||||||
|
engine["last_modified"] = timestamp
|
||||||
|
engine["schema"] = timestamp
|
||||||
|
elif "id" in engine and engine["id"] == YANDEX_SEARCH_ENGINE_ID:
|
||||||
|
yandex_search_engine_inserted = True
|
||||||
|
search_config["data"][i] = YANDEX_SEARCH_ENGINE_SECTION
|
||||||
|
|
||||||
|
search_config["timestamp"] = timestamp
|
||||||
|
if not yandex_search_engine_inserted:
|
||||||
|
search_config["data"] = [YANDEX_SEARCH_ENGINE_SECTION] + search_config["data"]
|
||||||
|
|
||||||
|
with open(search_config_path, 'w', encoding='utf8') as f:
|
||||||
|
json.dump(search_config, f, ensure_ascii=False, indent=2)
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
search_config_icons = None
|
||||||
|
with open(search_config_icons_path) as f:
|
||||||
|
search_config_icons = json.load(f)
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
yandex_icon_inserted = False
|
||||||
|
for i, icon in enumerate(search_config_icons["data"]):
|
||||||
|
if "id" in icon and icon["id"] == YANDEX_ICON_ID:
|
||||||
|
yandex_icon_inserted = True
|
||||||
|
search_config_icons["data"][i] = YANDEX_ICON_SECTION
|
||||||
|
|
||||||
|
search_config_icons["timestamp"] = timestamp
|
||||||
|
if not yandex_icon_inserted:
|
||||||
|
search_config_icons["data"] = [YANDEX_ICON_SECTION] + search_config_icons["data"]
|
||||||
|
|
||||||
|
with open(search_config_icons_path, 'w', encoding='utf8') as f:
|
||||||
|
json.dump(search_config_icons, f, ensure_ascii=False, indent=2)
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
with open(yandex_icon_meta_path, 'w', encoding='utf8') as f:
|
||||||
|
json.dump(YANDEX_ICON_SECTION, f, ensure_ascii=False)
|
||||||
|
f.close()
|
||||||
|
|
||||||
inserted = False
|
YANDEX_ICON_RELATIVE_DIR = "services/settings/dumps/main/search-config-icons/"
|
||||||
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:
|
src_icon_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), YANDEX_ICON_ID)
|
||||||
search_config["data"] = [YANDEX_SECTION] + search_config["data"]
|
dst_icon_path = os.path.join(YANDEX_ICON_RELATIVE_DIR, YANDEX_ICON_ID)
|
||||||
|
|
||||||
search_config["timestamp"] = int( datetime.datetime.now().timestamp() ) * 1000
|
shutil.copy(src_icon_path, dst_icon_path)
|
||||||
|
|
||||||
with open(sys.argv[1], 'w') as f:
|
exit(0)
|
||||||
json.dump(search_config, f, indent=2)
|
|
||||||
|
Loading…
Reference in new issue