From 5ae29310c8d1162e05f3b3b50836e3db8faeefae Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Wed, 20 Apr 2022 23:49:11 +0100 Subject: [PATCH] feat(userscripts/kagi-for-safer): redirect from yahoo instead of duckduckgo There's legit reasons why I might want to search with DuckDuckGo, and no reason why I might want to search with Yahoo. Specially as Yahoo now uses Bing to provide search results. Also, in my very basic testing, Yahoo actually produces a smaller and faster to load results page. So I might as well use that for the sake of performance, though I doubt it makes much of a difference, as the redirect logic runs immediately as the page starts loading. --- userscripts/kagi-for-safari.user.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/userscripts/kagi-for-safari.user.js b/userscripts/kagi-for-safari.user.js index 1ea5a80..0328af8 100644 --- a/userscripts/kagi-for-safari.user.js +++ b/userscripts/kagi-for-safari.user.js @@ -1,21 +1,23 @@ // ==UserScript== -// @name Kagi Search (DuckDuckGo redirect) -// @description Redirects DuckDuckGo searches to Kagi.com. Only relevant for desktop Safari users. -// @version 0.0.2 +// @name Kagi Search (Yahoo redirect) +// @description Redirects Yahoo searches to Kagi.com. Only relevant for desktop Safari users. +// @version 0.0.3 // @namespace jimeh.me // @downloadURL https://github.com/jimeh/dotfiles/blob/main/userscripts/kagi-for-safari.user.js // @run-at document-start -// @match https://duckduckgo.com/* +// @match https://yahoo.com/search* +// @match https://search.yahoo.com/search* +// @match https://*.search.yahoo.com/search* // ==/UserScript== (function () { if ( navigator.vendor.match(/apple/i) && // Only activate in Safari. - window.location.hostname == "duckduckgo.com" && - window.location.pathname == "/" + window.location.hostname.slice(-16) == "search.yahoo.com" && + window.location.pathname == "/search" ) { - let q = (new URL(window.location)).searchParams.get("q"); + let q = (new URL(window.location)).searchParams.get("p"); if (q) { - console.log("Redirecting DuckDuckGo search to Kagi.com"); + console.log("Redirecting Yahoo search to Kagi.com"); window.location.href = "https://kagi.com/search?q=" + q; } }