Skip to content

Instantly share code, notes, and snippets.

@AliMilani
Last active April 28, 2025 08:13
Show Gist options
  • Save AliMilani/9e672917372e4443e69aefe4aec3c0a8 to your computer and use it in GitHub Desktop.
Save AliMilani/9e672917372e4443e69aefe4aec3c0a8 to your computer and use it in GitHub Desktop.
javascript:(function() {
var scripts = document.getElementsByTagName("script");
var regex = /(\"|\'|\`)(\/[a-zA-Z0-9_?&=\/\-\#\.]*)(\"|\'|\`)/g;
const results = new Set();
function extractPaths(content) {
let match;
while ((match = regex.exec(content)) !== null) {
results.add(match[2]); // Capture group 2 contains the path
}
}
// Extract paths from external scripts
for (var i = 0; i < scripts.length; i++) {
var src = scripts[i].src;
if (src) {
fetch(src)
.then(response => response.text())
.then(text => extractPaths(text))
.catch(error => console.error("Error fetching external script:", error));
}
}
// Extract paths from the current page content
extractPaths(document.documentElement.outerHTML);
// Display results after a delay
setTimeout(() => {
let output = "";
results.forEach(path => output += path + "<br>");
document.body.innerHTML = output; // Append results to the body instead of overwriting
}, 3000);
})();
javascript:(async function(){let scanningDiv=document.createElement("div");scanningDiv.style.position="fixed",scanningDiv.style.bottom="0",scanningDiv.style.left="0",scanningDiv.style.width="100%",scanningDiv.style.maxHeight="50%",scanningDiv.style.overflowY="scroll",scanningDiv.style.backgroundColor="white",scanningDiv.style.color="black",scanningDiv.style.padding="10px",scanningDiv.style.zIndex="9999",scanningDiv.style.borderTop="2px solid black",scanningDiv.innerHTML="<h4>Scanning...</h4>",document.body.appendChild(scanningDiv);let e=[],t=new Set;async function n(e){try{const t=await fetch(e);return t.ok?await t.text():(console.error(`Failed to fetch ${e}: ${t.status}`),null)}catch(t){return console.error(`Error fetching ${e}:`,t),null}}function o(e){return(e.startsWith("/")||e.startsWith("./")||e.startsWith("../"))&&!e.includes(" ")&&!/[^\x20-\x7E]/.test(e)&&e.length>1&&e.length<200}function s(e){return[...e.matchAll(/['"]((?:\/|\.\.\/|\.\/)[^'"]+)['"]/g)].map(e=>e[1]).filter(o)}async function c(o){if(t.has(o))return;t.add(o),console.log(`Fetching and processing: ${o}`);const c=await n(o);if(c){const t=s(c);e.push(...t)}}const l=performance.getEntriesByType("resource").map(e=>e.name);console.log("Resources found:",l);for(const e of l)await c(e);const i=[...new Set(e)];console.log("Final list of unique paths:",i),console.log("All scanned resources:",Array.from(t)),scanningDiv.innerHTML=`<h4>Unique Paths Found:</h4><ul>${i.map(e=>`<li>${e}</li>`).join("")}</ul>`})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment