From 5b83279202ed0cd2aa63e9910d855763355bf6e4 Mon Sep 17 00:00:00 2001 From: ManagarmrWhisperer Date: Thu, 14 Mar 2024 23:20:47 +0100 Subject: [PATCH] feat(startpage): cleaned up code, added popup entries --- defaults.js | 4 + js/popup/SearchFilterSettings.js | 5 ++ js/search/startpage.js | 16 ++-- manifests/chrome_dev.json | 134 ------------------------------- 4 files changed, 16 insertions(+), 143 deletions(-) delete mode 100644 manifests/chrome_dev.json diff --git a/defaults.js b/defaults.js index e88e45f..daf5d79 100644 --- a/defaults.js +++ b/defaults.js @@ -43,7 +43,11 @@ export default function () { }, ddg: { mode: 'rewrite' + }, + startpage: { + mode: 'rewrite' } + } }; } diff --git a/js/popup/SearchFilterSettings.js b/js/popup/SearchFilterSettings.js index 4b171be..92cce1c 100644 --- a/js/popup/SearchFilterSettings.js +++ b/js/popup/SearchFilterSettings.js @@ -25,6 +25,11 @@ export default class SearchFilterSettings { supportsFilter: true, supportsRewrite: true, }, + { + id: 'startpage', + supportsFilter: true, + supportsRewrite: true, + } ]; diff --git a/js/search/startpage.js b/js/search/startpage.js index a11450e..8bb4f01 100644 --- a/js/search/startpage.js +++ b/js/search/startpage.js @@ -19,18 +19,17 @@ const wikis = prepareWikisInfo( getWikis( false, true ), { class DdgSearchModule extends GenericSearchModule { - ENGINE_LAYOUT_SELECTOR = '.w-gl--desktop'; - RESULT_CONTAINER_SELECTOR = '.w-gl__result'; - URL_ELEMENT_SELECTOR = '.w-gl__result-url'; - SPAN_TITLE_ELEMENT_SELECTOR = '.w-gl__result-title > h3'; - BADGE_ELEMENT_SELECTOR = '.w-gl__result-title'; - ANCHOR_ELEMENT_SELECTOR = '.w-gl__result-url'; // URL breadcumb + ENGINE_LAYOUT_SELECTOR = '.w-gl--desktop, .w-gl'; + RESULT_CONTAINER_SELECTOR = '.w-gl__result, .result'; + SPAN_TITLE_ELEMENT_SELECTOR = '.w-gl__result-title > h3, .result-title > h2 '; + BADGE_ELEMENT_SELECTOR = this.SPAN_TITLE_ELEMENT_SELECTOR; // Element that will hold the badge. + ANCHOR_ELEMENT_SELECTOR = '.w-gl__result-url, .css-1su0nhd > span, .css-1qvmgy0 > span'; // URL breadcumb /** * @protected * @return {string} */ getId() { - return 'ddg'; + return 'startpage'; } @@ -96,7 +95,7 @@ class DdgSearchModule extends GenericSearchModule { allMoved: true, theme: { fontSize: '80%', - color: document.documentElement.classList.contains("startpage-html--dark" || "startpage-html--night") ? '#a7b1fc' : '#000000', + color: document.documentElement.classList.contains("dark" || "startpage-html--night") ? '#a7b1fc' : '#000000', marginBottom: '1%', display: 'inline-block' } @@ -110,7 +109,6 @@ class DdgSearchModule extends GenericSearchModule { } } -debugger; document.onreadystatechange = () => { if (document.readyState === "complete") { DdgSearchModule.invoke( wikis ); diff --git a/manifests/chrome_dev.json b/manifests/chrome_dev.json deleted file mode 100644 index 6bd9ef2..0000000 --- a/manifests/chrome_dev.json +++ /dev/null @@ -1,134 +0,0 @@ -{ - "name": "__MSG_extension_name_dev__", - "author": "Freedom Games", - "version": "1.7.9910701", - "description": "__MSG_extension_desc__", - "default_locale": "en", - "permissions": [ - "storage", - "webNavigation" - ], - "host_permissions": [ - "*://*.gamepedia.com/*", - "*://*.fandom.com/*" - ], - "background": { - "service_worker": "built/background.js" - }, - "action": { - "default_icon": "icons/128_dev.png", - "default_title": "__MSG_extension_name_dev__", - "default_popup": "popup.html" - }, - "content_scripts": [ - { - "matches": [ - "https://www.google.at/*", - "https://www.google.be/*", - "https://www.google.ch/*", - "https://www.google.cl/*", - "https://www.google.ca/*", - "https://www.google.co.in/*", - "https://www.google.co.jp/*", - "https://www.google.co.kr/*", - "https://www.google.com/*", - "https://www.google.com.ar/*", - "https://www.google.com.au/*", - "https://www.google.com.br/*", - "https://www.google.com.co/*", - "https://www.google.com.gr/*", - "https://www.google.com.mx/*", - "https://www.google.com.pk/*", - "https://www.google.com.tr/*", - "https://www.google.com.tw/*", - "https://www.google.co.uk/*", - "https://www.google.de/*", - "https://www.google.dk/*", - "https://www.google.es/*", - "https://www.google.fr/*", - "https://www.google.ie/*", - "https://www.google.it/*", - "https://www.google.nl/*", - "https://www.google.pl/*", - "https://www.google.pt/*" - ], - "js": [ - "built/google.js" - ], - "run_at": "document_end" - }, - { - "matches": [ - "https://duckduckgo.com/*" - ], - "js": [ - "built/ddg.js" - ], - "run_at": "document_end" - }, - { - "matches": [ - "https://*.fandom.com/*" - ], - "js": [ - "built/fandom.js" - ], - "run_at": "document_end" - }, - { - "matches": [ - "https://www.startpage.com/sp/search/*" - ], - "js": [ - "built/startpage.js" - ], - "run_at": "document_end" - } - - - ], - "icons": { - "128": "icons/128_dev.png" - }, - "web_accessible_resources": [ - { - "resources": [ - "/icons/redirectBadge.svg" - ], - "matches": [ - "https://www.google.at/*", - "https://www.google.be/*", - "https://www.google.ch/*", - "https://www.google.cl/*", - "https://www.google.ca/*", - "https://www.google.co.in/*", - "https://www.google.co.jp/*", - "https://www.google.co.kr/*", - "https://www.google.com/*", - "https://www.google.com.ar/*", - "https://www.google.com.au/*", - "https://www.google.com.br/*", - "https://www.google.com.co/*", - "https://www.google.com.gr/*", - "https://www.google.com.mx/*", - "https://www.google.com.pk/*", - "https://www.google.com.tr/*", - "https://www.google.com.tw/*", - "https://www.google.co.uk/*", - "https://www.google.de/*", - "https://www.google.dk/*", - "https://www.google.es/*", - "https://www.google.fr/*", - "https://www.google.ie/*", - "https://www.google.it/*", - "https://www.google.nl/*", - "https://www.google.pl/*", - "https://www.google.pt/*", - "https://duckduckgo.com/*", - "https://www.bing.com/*", - "https://www.startpage.com/*" - ] - } - ], - "manifest_version": 3 -}