Skip to content

Instantly share code, notes, and snippets.

@MustCodeAl
Created January 6, 2026 21:12
Show Gist options
  • Select an option

  • Save MustCodeAl/6418d9536ce628448614263732e6e2be to your computer and use it in GitHub Desktop.

Select an option

Save MustCodeAl/6418d9536ce628448614263732e6e2be to your computer and use it in GitHub Desktop.
Install with tamper monkey, adds highlights to common links for developers, to increase your efficiency when googling
// ==UserScript==
// @name Google DevSearch Power Edition — Crawler Engine v9.1 (2025 Final)
// @description Ultra-stable universal crawler for Google SERPs with domain highlighting & filtering.
// @version 9.1
// @include *://www.google.*/*
// @run-at document-end
// @grant none
// ==/UserScript==
(() => {
'use strict';
/**********************************************************************
* 1. UNIVERSAL LINK SELECTORS — WORKS WITH YOUR REDDIT HTML
**********************************************************************/
const LINK_SELECTORS = `
a[href^="http"],
a[href^="/url"],
a[jsname][href],
a[data-ved][href],
a[role="link"][href],
div[jscontroller] a[href]
`;
/**********************************************************************
* 2. URL EXTRACTION ENGINE — MATCHES YOUR EXACT SNIPPET
**********************************************************************/
function extractRealURL(a) {
try {
// Direct normal URL (Google now does this for Reddit)
if (a.href && a.href.startsWith("http"))
return a.href;
const h = a.getAttribute("href");
if (h && h.startsWith("/url?")) {
const q = new URLSearchParams(h.split("?")[1]).get("q");
if (q && q.startsWith("http")) return q;
}
// URL buried inside data-ved
const dved = a.getAttribute("data-ved") || "";
const m1 = dved.match(/https?:\/\/[^\s"'<>]+/);
if (m1) return m1[0];
// URL inside JS metadata inside children (image search patterns)
const html = a.innerHTML;
const m2 = html.match(/https?:\/\/[^\s"'<>]+/);
if (m2) return m2[0];
} catch (e) {}
return null;
}
/**********************************************************************
* 3. HOST NORMALIZATION
**********************************************************************/
function getHost(url) {
try { return new URL(url).hostname.replace(/^www\./, ""); }
catch { return ""; }
}
/**********************************************************************
* 4. UNIVERSAL RESULT BOX DETECTOR
* — This is what makes Reddit & new SERP layouts highlight again.
**********************************************************************/
function getBox(el) {
let n = el.parentElement;
while (n) {
if (
n.matches("div.g") || // old Google result
n.matches("div.MjjYud") || // newer Google result
n.matches("div[data-hveid]") || // informational cards
n.matches("div[data-ved]") || // all SERP modules
n.matches("div[jscontroller]") || // weird mixed modules
n.matches("a[jsname]") || // SGE / AI modules
n.matches("div:not(:has(a[href]))") // fallback safe container
) {
return n;
}
n = n.parentElement;
}
return null;
}
/**********************************************************************
* 5. DOMAIN CATEGORIES (trimmed but complete — Reddit fixed)
**********************************************************************/
const SITES = {
reference:new Set([
"developer.mozilla.org","docs.microsoft.com","learn.microsoft.com",
"rust-lang.org","python.org","postgresql.org",
"wiki.osdev.org","os.phil-opp.com","attack.mitre.org"
]),
recommend:new Set([
"roadmap.sh","refactoring.guru","devdocs.io","devhints.io",
"libhunt.com","alternativeto.net","awesome-selfhosted.com"
]),
security:new Set([
"hacktricks.xyz","portswigger.net","ctf101.org",
"vx-underground.org","haveibeenpwned.com","grep.app"
]),
privacy:new Set([
"privacyguides.org","privacytools.io","anonymousplanet.org",
"browserleaks.com"
]),
tools:new Set([
"godbolt.org","dogbolt.org","regex-generator.olafneumann.org",
"codebeautify.org","openvim.com","cmdchallenge.com"
]),
courses:new Set([
"khanacademy.org","codecademy.com","sololearn.com",
"teachyourselfcs.com"
]),
search_engines:new Set([
"you.com","perplexity.ai","phind.com","metager.org","qwant.com"
]),
books:new Set([
"beej.us","cses.fi","visualgo.net","algs4.cs.princeton.edu"
]),
practice:new Set([
"exercism.org","codewars.com","hackthebox.com","tryhackme.com",
"overthewire.org"
]),
media:new Set([
"videocopilot.net","texturelabs.org","greyscalegorilla.com"
]),
public:new Set(["qiita.com"]),
forum:new Set([
"reddit.com", // <-- THIS FIXES YOUR REDDIT RESULT
"old.reddit.com",
"m.reddit.com",
"stackexchange.com",
"stackoverflow.com",
"medium.com"
]),
blacklist:new Set([
"softonic.com","dll-files.com","systweak.com","chip.de",
"reviversoft.com","tutorialmore.com","voidcc.com","it-swarm.dev"
])
};
/**********************************************************************
* 6. SETTINGS (minimal version for stability)
**********************************************************************/
const SETTINGS = {
enabled:true,
blockBlacklist:true,
highlightReference:true,
highlightRecommend:true,
highlightSecurity:true,
highlightPrivacy:true,
highlightTools:true,
highlightCourses:true,
highlightSearch:true,
highlightBooks:true,
highlightPractice:true,
highlightMedia:true,
highlightPublic:true,
highlightForum:true // <-- Reddit category
};
/**********************************************************************
* 7. CATEGORY COLORS
**********************************************************************/
const COLORS = {
reference:"#D0F2FF",
recommend:"#D7FFE5",
security:"#FFE0E0",
privacy:"#E6E0FF",
tools:"#FFF0D5",
courses:"#D5F0FF",
search:"#F0D5FF",
books:"#E0FFD5",
practice:"#FFF5D5",
media:"#F8E8FF",
public:"#F5CCFF",
forum:"#FFECCF"
};
/**********************************************************************
* 8. CATEGORY MATCHER (with subdomain support)
**********************************************************************/
function domainMatch(h,set) {
return [...set].some(d => h===d || h.endsWith("."+d));
}
function classify(h){
if (SETTINGS.blockBlacklist && domainMatch(h,SITES.blacklist)) return "blacklist";
if (SETTINGS.highlightForum && domainMatch(h,SITES.forum)) return "forum";
if (SETTINGS.highlightReference && domainMatch(h,SITES.reference)) return "reference";
if (SETTINGS.highlightRecommend && domainMatch(h,SITES.recommend)) return "recommend";
if (SETTINGS.highlightSecurity && domainMatch(h,SITES.security)) return "security";
if (SETTINGS.highlightPrivacy && domainMatch(h,SITES.privacy)) return "privacy";
if (SETTINGS.highlightTools && domainMatch(h,SITES.tools)) return "tools";
if (SETTINGS.highlightCourses && domainMatch(h,SITES.courses)) return "courses";
if (SETTINGS.highlightSearch && domainMatch(h,SITES.search_engines)) return "search";
if (SETTINGS.highlightBooks && domainMatch(h,SITES.books)) return "books";
if (SETTINGS.highlightPractice && domainMatch(h,SITES.practice)) return "practice";
if (SETTINGS.highlightMedia && domainMatch(h,SITES.media)) return "media";
if (SETTINGS.highlightPublic && domainMatch(h,SITES.public)) return "public";
return null;
}
/**********************************************************************
* 9. HIGHLIGHT + TAGGING
**********************************************************************/
function highlightBox(box,c){
box.style.setProperty("background",c,"important");
box.style.setProperty("background-color",c,"important");
}
function addTag(box,text){
if(box.querySelector(".gdev-tag")) return;
let s=document.createElement("span");
s.textContent=text;
s.style=`
background:#e5e7eb;
padding:2px 6px;
font-size:10px;
margin-left:6px;
border-radius:6px;
font-weight:600;
`;
const h=box.querySelector("h3");
if(h) h.appendChild(s);
}
function addRemoveBtn(box){
if(box.querySelector(".gdev-remove")) return;
let b=document.createElement("button");
b.innerHTML="&#10005;";
b.style=`
position:absolute;top:6px;right:8px;width:18px;height:18px;
border:none;border-radius:50%;background:#e5e7eb;color:#444;
display:flex;justify-content:center;align-items:center;
cursor:pointer;font-size:12px;
`;
b.onclick=e=>{e.stopPropagation();box.remove();};
box.style.position="relative";
box.appendChild(b);
}
/**********************************************************************
* 10. PROCESS ENTIRE PAGE
**********************************************************************/
function process(root=document){
root.querySelectorAll(LINK_SELECTORS).forEach(a=>{
const url = extractRealURL(a);
if(!url || !url.startsWith("http")) return;
const h = getHost(url);
if(!h) return;
const cat = classify(h);
if(!cat) return;
const box = getBox(a);
if(!box) return;
if(cat==="blacklist") { box.remove(); return; }
highlightBox(box, COLORS[cat]);
addTag(box, cat);
addRemoveBtn(box);
});
}
/**********************************************************************
* 11. REAL-TIME MUTATION OBSERVER
**********************************************************************/
new MutationObserver(m => {
for(const r of m)
for(const n of r.addedNodes)
if(n.nodeType===1) process(n);
}).observe(document.body,{childList:true,subtree:true});
/**********************************************************************
* 12. INITIAL EXECUTION
**********************************************************************/
process();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment