Skip to content

Instantly share code, notes, and snippets.

@foriequal0
Last active May 20, 2024 10:45
Show Gist options
  • Save foriequal0/32290e22f59e6c7c6ff524c46716eae2 to your computer and use it in GitHub Desktop.
Save foriequal0/32290e22f59e6c7c6ff524c46716eae2 to your computer and use it in GitHub Desktop.
Google was a web search engine
// ==UserScript==
// @name Google was a web search engine
// @description Redirect to new Google Web search page
// @match https://www.google.com/search*
// @run-at document-start
// @updateURL https://gist.github.com/foriequal0/32290e22f59e6c7c6ff524c46716eae2/raw/google-was-a-web-search-engine.user.js
// @version 0.0.1
// ==/UserScript==
const KEY = "$__google-was-a-web-search-engine";
const url = new URL(location.href);
function isAll() {
// The 'Web' search
if (url.searchParams.get("udm") === "14") {
return false;
}
// other searches (e.g. udm=2 for Images)
const udm = url.searchParams.get("udm");
if (udm) {
return false;
}
// another searches (e.g. tbm=vid, tbm=shop, tbm=nes, tbm=bks, ...)
const tbm = url.searchParams.get("tbm");
if (tbm) {
return false;
}
return true;
}
if (!isAll()) {
return;
}
if (sessionStorage.getItem(KEY) === "1") {
return;
}
sessionStorage.setItem(KEY, "1");
url.searchParams.append("udm", "14");
location.href = url.href;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment