about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--src/assets/javascripts/services.js19
-rw-r--r--src/config.json35
-rw-r--r--src/pages/options_src/Services/Services.svelte12
3 files changed, 53 insertions, 13 deletions
diff --git a/src/assets/javascripts/services.js b/src/assets/javascripts/services.js
index 9b6ef325..60135b73 100644
--- a/src/assets/javascripts/services.js
+++ b/src/assets/javascripts/services.js
@@ -33,12 +33,14 @@ function all(service, frontend, options, config) {
  * @param {{}} config
  * @param {string} frontend
  */
-function regexArray(service, url, config, frontend) {
+function regexArray(service, url, config, options, frontend) {
   let targetList = config.services[service].targets
   if (frontend && "excludeTargets" in config.services[service].frontends[frontend]) {
-    targetList = targetList.filter(
-      val => !config.services[service].frontends[frontend].excludeTargets.includes(targetList.indexOf(val))
-    )
+    if (service !== "search" || !options['search'].redirectGoogle) {
+      targetList = targetList.filter(
+        val => !config.services[service].frontends[frontend].excludeTargets.includes(targetList.indexOf(val))
+      )
+    }
   }
   for (const targetString in targetList) {
     const target = new RegExp(targetList[targetString])
@@ -67,13 +69,17 @@ async function redirectAsync(url, type, initiator, forceRedirection) {
 function rewrite(url, frontend, randomInstance) {
   switch (frontend) {
     case "hyperpipe":
+      for (const key of [...url.searchParams.keys()]) if (key !== "q") url.searchParams.delete(key)
       return `${randomInstance}${url.pathname}${url.search}`.replace(/\/search\?q=.*/, searchQuery =>
         searchQuery.replace("?q=", "/")
       )
     case "searx":
     case "searxng":
+      for (const key of [...url.searchParams.keys()]) if (key !== "q") url.searchParams.delete(key)
+      console.log(url.searchParams)
       return `${randomInstance}/${url.search}`
     case "whoogle":
+      for (const key of [...url.searchParams.keys()]) if (key !== "q") url.searchParams.delete(key)
       return `${randomInstance}/search${url.search}`
     case "4get": {
       const s = url.searchParams.get("q")
@@ -81,6 +87,7 @@ function rewrite(url, frontend, randomInstance) {
       return randomInstance
     }
     case "librey":
+      for (const key in url.searchParams.keys()) if (key != "q") url.searchParams.delete(key)
       return `${randomInstance}/search.php${url.search}`
     case "yattee":
       url.searchParams.delete("si")
@@ -609,7 +616,7 @@ function redirect(url, type, initiator, forceRedirection, incognito) {
     )
       frontend = options[service].embedFrontend
 
-    if (!regexArray(service, url, config, frontend)) {
+    if (!regexArray(service, url, config, options, frontend)) {
       frontend = null
       continue
     }
@@ -652,7 +659,7 @@ function computeService(url, returnFrontend) {
     const config = await utils.getConfig()
     const options = await utils.getOptions()
     for (const service in config.services) {
-      if (regexArray(service, url, config)) {
+      if (regexArray(service, url, config, options)) {
         resolve(service)
         return
       } else {
diff --git a/src/config.json b/src/config.json
index 16bd9076..7a300125 100644
--- a/src/config.json
+++ b/src/config.json
@@ -993,38 +993,61 @@
           "name": "SearXNG",
           "instanceList": true,
           "url": "https://github.com/searxng/searxng",
-          "localhost": true
+          "localhost": true,
+          "excludeTargets": [
+            2,
+            3
+          ]
         },
         "searx": {
           "name": "SearX",
           "instanceList": true,
-          "url": "https://searx.github.io/searx/"
+          "url": "https://searx.github.io/searx/",
+          "excludeTargets": [
+            2,
+            3
+          ]
         },
         "whoogle": {
           "name": "Whoogle",
           "instanceList": true,
-          "url": "https://benbusby.com/projects/whoogle-search/"
+          "url": "https://benbusby.com/projects/whoogle-search/",
+          "excludeTargets": [
+            2,
+            3
+          ]
         },
         "librey": {
           "name": "LibreY",
           "instanceList": true,
-          "url": "https://github.com/Ahwxorg/librey/"
+          "url": "https://github.com/Ahwxorg/librey/",
+          "excludeTargets": [
+            2,
+            3
+          ]
         },
         "4get": {
           "name": "4get",
           "instanceList": true,
-          "url": "https://git.lolcat.ca/lolcat/4get"
+          "url": "https://git.lolcat.ca/lolcat/4get",
+          "excludeTargets": [
+            2,
+            3
+          ]
         }
       },
       "targets": [
         "^https?:\\/{2}search\\.libredirect\\.invalid",
-        "^https?:\\/{2}libredirect\\.github\\.io\\/\\?q"
+        "^https?:\\/{2}libredirect\\.github\\.io\\/\\?q",
+        "^https?:\\/{2}(www\\.)?google\\.com",
+        "^https?:\\/{2}(www\\.)?bing\\.com"
       ],
       "name": "Search",
       "options": {
         "enabled": false,
         "frontend": "searxng",
         "unsupportedUrls": "bypass",
+        "redirectGoogle": false,
         "instance": "public"
       },
       "imageType": "svgMono",
diff --git a/src/pages/options_src/Services/Services.svelte b/src/pages/options_src/Services/Services.svelte
index 6b16e824..f858a3bd 100644
--- a/src/pages/options_src/Services/Services.svelte
+++ b/src/pages/options_src/Services/Services.svelte
@@ -116,7 +116,7 @@
           {browser.i18n.getMessage("frontend") || "Frontend"}
         </a>
       </Label>
-      <div dir="ltr"  on:click={() => (hideFrontendSelection = true)} on:keydown={null}>
+      <div dir="ltr" on:click={() => (hideFrontendSelection = true)} on:keydown={null}>
         <SvelteSelect
           clearable={false}
           dir="ltr"
@@ -173,6 +173,16 @@
 
     {#if selectedService == "search"}
       <Row>
+        <Label>{browser.i18n.getMessage("redirectGoogle") || "Redirect Google"}</Label>
+        <Checkbox
+          checked={serviceOptions.redirectGoogle}
+          onChange={e => {
+            serviceOptions.redirectGoogle = e.target.checked
+            options.set(_options)
+          }}
+        />
+      </Row>
+      <Row>
         <Label>
           {@html browser.i18n.getMessage("searchHint") ||
             `Set LibRedirect as Default Search Engine. For how to do in chromium browsers, click