Skip to content

Instantly share code, notes, and snippets.

@mhmdiaa
Created August 6, 2023 20:22
Show Gist options
  • Save mhmdiaa/dc24c06ab18ebe90df8981cd7b25a548 to your computer and use it in GitHub Desktop.
Save mhmdiaa/dc24c06ab18ebe90df8981cd7b25a548 to your computer and use it in GitHub Desktop.
All credit goes to @renniepak for the original bookmarklet https://twitter.com/renniepak/status/1602620834463588352
javascript: (function() {
var scripts = document.getElementsByTagName("script"),
regex = /(?<=(\"|\%27|\`))\/[a-zA-Z0-9_?&=\/\-\#\.]*(?=(\"|\'|\%60))/g;
const results = new Set;
for (var i = 0; i < scripts.length; i++) {
var t = scripts[i].src;
"" != t && fetch(t).then(function(t) {
return t.text()
}).then(function(t) {
var e = t.matchAll(regex);
for (let r of e) results.add(r[0])
}).catch(function(t) {
console.log("An error occurred: ", t)
})
}
var pageContent = document.documentElement.outerHTML,
matches = pageContent.matchAll(regex);
for (const match of matches) results.add(match[0]);
function writeResults() {
var newTab = window.open("", "_blank");
if (newTab) {
results.forEach(function(t) {
newTab.document.write(t + "<br>");
});
newTab.document.close();
} else {
results.forEach(function(t) {
document.write(t + "<br>");
})
}
}
setTimeout(writeResults, 3e3);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment