Skip to content

Instantly share code, notes, and snippets.

@electro0nes
Created July 5, 2025 17:38
Show Gist options
  • Save electro0nes/bd5de35c2bc8f5ca0db1eea2bf5f7cbf to your computer and use it in GitHub Desktop.
Save electro0nes/bd5de35c2bc8f5ca0db1eea2bf5f7cbf to your computer and use it in GitHub Desktop.
logs all URLs loaded and requested on any webpage in real-time, displaying them in a neat bottom panel!
javascript:(()=>{if(window.__urlHookInjected)return;window.__urlHookInjected=!0;const t=/https?:\/\/[^\s"%27<>]+/gi,e=new Set,o=o=>{const c=o.match(t);c&&c.forEach((t=>{e.has(t)||(e.add(t),function(t){const e=document.createElement("div");e.textContent=t,n.appendChild(e),n.scrollTop=n.scrollHeight}(t),console.log(`[URL Hook] ${o}`))}))},n=document.createElement("div");n.style.position="fixed",n.style.bottom="0",n.style.left="0",n.style.width="100%",n.style.maxHeight="150px",n.style.overflowY="auto",n.style.backgroundColor="rgba(0,0,0,0.85)",n.style.color="lime",n.style.fontFamily="monospace",n.style.fontSize="12px",n.style.zIndex="9999999999",n.style.padding="5px 10px",n.style.borderTop="3px solid lime",n.innerHTML="<strong>URL Hook Panel</strong><br>",document.body.appendChild(n);const c=XMLHttpRequest.prototype.open;XMLHttpRequest.prototype.open=function(t,e){return o(`[XHR] ${t}: ${e}`),c.apply(this,arguments)};const r=window.fetch;window.fetch=function(t,e){const n="string"==typeof t?t:t&&t.url;return n&&o(`[Fetch] URL: ${n}`),r.apply(this,arguments)};const s=history.pushState;history.pushState=function(t,e,n){return n&&o(`[History] pushState: ${n}`),s.apply(this,arguments)};const i=history.replaceState;history.replaceState=function(t,e,n){return n&&o(`[History] replaceState: ${n}`),i.apply(this,arguments)};const a=document.createElement;document.createElement=function(e,n){const c=a.call(document,e,n);if(["script","iframe","img","link","audio","video","source"].includes(e.toLowerCase())){const n=c.setAttribute;c.setAttribute=function(c,r){return["src","href"].includes(c)&&r&&t.test(r)&&o(`[Element Hook] <${e}> ${c}: ${r}`),n.apply(this,arguments)}}return c};async function l(){try{const e=document.getElementsByTagName("script");for(let t=0;t<e.length;t++){const n=e[t].src;if(n)try{const t=await fetch(n);if(!t.ok)continue;const e=await t.text();let c;const r=/https?:\/\/[^\s"%27<>]+/gi;for(;null!==(c=r.exec(e));)o(`[Script Source] ${c[0]}`)}catch(t){console.warn("Error fetching script:",t)}}[...document.scripts].filter((t=>!t.src)).forEach((e=>{const n=e.textContent.match(t);n&&n.forEach((t=>o(`[Inline Script] ${t}`)))}))}catch(t){console.warn("Error scanning scripts:",t)}}new MutationObserver((e=>{e.forEach((e=>{e.addedNodes.forEach((e=>{if(e.nodeType===Node.TEXT_NODE&&e.textContent&&t.test(e.textContent))o(`[DOM] Text Node URL: ${e.textContent.trim()}`);else if(e.nodeType===Node.ELEMENT_NODE){Array.from(e.attributes||[]).filter((e=>e.value&&t.test(e.value))).forEach((t=>o(`[DOM] Attribute URL: ${t.name}=${t.value}`)))}}))}))})).observe(document.body,{childList:!0,subtree:!0,attributes:!0}),document.addEventListener("click",(e=>{const n=e.target.closest("a");n&&n.href&&t.test(n.href)&&o(`[Click] <a> href: ${n.href}`)})),document.addEventListener("submit",(e=>{const n=e.target;n.action&&t.test(n.action)&&o(`[Form Submit] action: ${n.action}`)})),"complete"===document.readyState||"interactive"===document.readyState?l():window.addEventListener("DOMContentLoaded",l),console.log("%c🌐 Enhanced URL Hook Initialized! Panel at bottom.","color: lime; font-weight: bold;")})();
@pythonAndCplusplus
Copy link

This is Awsome, you can use it in nearly everywhere

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment