aboutsummaryrefslogtreecommitdiff
path: root/addons/qwantjunior
diff options
context:
space:
mode:
authortilpner2020-06-15 09:53:06 +0200
committertilpner2020-06-15 09:53:06 +0200
commit367b0c114f38d5c332f5ee971ad13dd69e302dec (patch)
treeec0c5ee3e7e1f0a30517599e51bd0c8172635158 /addons/qwantjunior
parent2992d92e6ce0d7c96ccded0747d8815d8cfed956 (diff)
downloadfirefox-profiles-367b0c114f38d5c332f5ee971ad13dd69e302dec.tar.gz
firefox-profiles-367b0c114f38d5c332f5ee971ad13dd69e302dec.tar.xz
firefox-profiles-367b0c114f38d5c332f5ee971ad13dd69e302dec.zip
WIP towards module based configuration
Diffstat (limited to 'addons/qwantjunior')
-rw-r--r--addons/qwantjunior/content-script.js34
-rw-r--r--addons/qwantjunior/favicon.icobin0 -> 2285 bytes
-rw-r--r--addons/qwantjunior/managed_storage.json20
-rw-r--r--addons/qwantjunior/manifest.json40
4 files changed, 94 insertions, 0 deletions
diff --git a/addons/qwantjunior/content-script.js b/addons/qwantjunior/content-script.js
new file mode 100644
index 0000000..01b3976
--- /dev/null
+++ b/addons/qwantjunior/content-script.js
@@ -0,0 +1,34 @@
+"use strict";
+
+function changeSettings(managed) {
+ var preferred = managed.settings;
+ var userStorage = JSON.parse(localStorage.getItem('user'));
+ var needsReload = false;
+
+ if (userStorage == null) {
+ localStorage.setItem('user', JSON.stringify({
+ userSetting: preferred
+ }));
+
+ needsReload = true;
+ } else if (userStorage.version == "2") {
+ var setting = userStorage.userSetting;
+
+ for (const [key, value] of Object.entries(preferred)) {
+ if (setting[key] != preferred[key]) {
+ setting[key] = preferred[key];
+ needsReload = true;
+ }
+ }
+
+ localStorage.setItem('user', JSON.stringify(userStorage));
+ }
+
+ if (needsReload) {
+ location.reload();
+ }
+}
+
+browser.storage.managed
+ .get("settings")
+ .then(changeSettings);
diff --git a/addons/qwantjunior/favicon.ico b/addons/qwantjunior/favicon.ico
new file mode 100644
index 0000000..5e44aac
--- /dev/null
+++ b/addons/qwantjunior/favicon.ico
Binary files differ
diff --git a/addons/qwantjunior/managed_storage.json b/addons/qwantjunior/managed_storage.json
new file mode 100644
index 0000000..00afb5a
--- /dev/null
+++ b/addons/qwantjunior/managed_storage.json
@@ -0,0 +1,20 @@
+{
+ "$schema": "http://json-schema.org/draft-03/schema#",
+ "type": "object",
+ "properties": {
+ "settings": {
+ "type": "object",
+ "properties": {
+ "searchRegionKey": {
+ "type": "string"
+ },
+ "searchLanguageKey": {
+ "type": "string"
+ },
+ "interfaceLanguageKey": {
+ "type": "string"
+ }
+ }
+ }
+ }
+}
diff --git a/addons/qwantjunior/manifest.json b/addons/qwantjunior/manifest.json
new file mode 100644
index 0000000..f38a086
--- /dev/null
+++ b/addons/qwantjunior/manifest.json
@@ -0,0 +1,40 @@
+{
+ "name": "QwantJunior",
+ "description": "Search Qwant Junior",
+ "manifest_version": 2,
+ "version": "1.0",
+ "applications": {
+ "gecko": {
+ "id": "qwantjunior@search.mozilla.org"
+ }
+ },
+ "hidden": true,
+ "icons": {
+ "16": "favicon.ico"
+ },
+ "web_accessible_resources": [
+ "favicon.ico"
+ ],
+ "chrome_settings_overrides": {
+ "search_provider": {
+ "is_default": true,
+ "name": "Qwant Junior",
+ "search_url": "https://www.qwantjunior.com",
+ "search_form": "https://www.qwantjunior.com/?q={searchTerms}",
+ "search_url_get_params": "q={searchTerms}",
+ "suggest_url": "https://api.qwant.com/egp/suggest/",
+ "suggest_url_get_params": "q={searchTerms}&client=opensearch"
+ }
+ },
+
+ "permissions": [
+ "storage",
+ "https://www.qwantjunior.com/*"
+ ],
+
+ "content_scripts": [
+ { "matches": [ "https://www.qwantjunior.com/*" ],
+ "run_at": "document_idle",
+ "js": [ "content-script.js" ] }
+ ]
+}