Files
dotfiles/userscripts/kagi-for-safari.user.js
Jim Myhrberg 5ae29310c8 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.
2022-04-20 23:49:11 +01:00

25 lines
908 B
JavaScript

// ==UserScript==
// @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://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.slice(-16) == "search.yahoo.com" &&
window.location.pathname == "/search"
) {
let q = (new URL(window.location)).searchParams.get("p");
if (q) {
console.log("Redirecting Yahoo search to Kagi.com");
window.location.href = "https://kagi.com/search?q=" + q;
}
}
})();