mirror of
https://github.com/jimeh/dotfiles.git
synced 2026-02-19 04:46:41 +00:00
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.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user