Skip to content

Instantly share code, notes, and snippets.

@Taraflex
Last active November 23, 2024 20:29
Show Gist options
  • Save Taraflex/1b024ec68dfd29dd15c30435350bb991 to your computer and use it in GitHub Desktop.
Save Taraflex/1b024ec68dfd29dd15c30435350bb991 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name distraction_free_google_search
// @namespace mailto:[email protected]
// @version 0.0.2
// @author Taraflex <[email protected]>
// @description Unwrap urls in google search and simplify styles
// @license MIT
// @match https://www.google.com/search*
// @match https://www.google.ru/search*
// @match https://google.com/search*
// @match https://google.ru/search*
// @run-at document-start
// @grant GM_addStyle
// @noframes
// @downloadUrl https://gist.github.com/Taraflex/1b024ec68dfd29dd15c30435350bb991/raw/distraction_free_google_search.user.js
// @updateURL https://gist.github.com/Taraflex/1b024ec68dfd29dd15c30435350bb991/raw/distraction_free_google_search.user.js
// ==/UserScript==
GM_addStyle(`
*{
margin-bottom: 0 !important;
}
body > :nth-child(3) * {
border-top: 0 !important;
border-left: 0 !important;
border-right: 0 !important;
}
body{
max-width: 900px !important;
}
a > :nth-child(1) {
color: #1967d2 !important;
}
a:visited > :nth-child(1) {
color: #551A8B !important;
}
`)
function onReady() {
document.querySelectorAll(`a[href^="/url?"],a[href^="${location.origin.replace('https://', 'http://')}/url?"]`).forEach((a) => {
a.href = new URLSearchParams(a.href.slice(a.href.indexOf('?'))).get("url");
});
}
if (
document.readyState === "interactive" ||
document.readyState === "complete"
) {
onReady();
} else {
document.addEventListener("DOMContentLoaded", onReady);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment