Last active
November 11, 2024 08:37
-
-
Save sttuartt/a4e9682784c5f3920f5cba2c4f434ac7 to your computer and use it in GitHub Desktop.
js-endpoints
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:(function(){var scripts=document.getElementsByTagName("script"),regex=/(?<=(\"|\'|\`))\/[a-zA-Z0-9_?&=\/\-\#\.]*(?=(\"|\'|\`))/g,results=new Set;Promise.all(Array.from(scripts).map(script=>{var src=script.src;if(src){return fetch(src).then(response=>response.text()).then(content=>{var matches=content.matchAll(regex);for(let match of matches){results.add(src+": "+match[0])}}).catch(error=>{console.log("An error occurred: ",error)})}})).then(()=>{var pageContent=document.documentElement.outerHTML,matches=pageContent.matchAll(regex);for(const match of matches){results.add("HTML Content: "+match[0])}writeResults()});function writeResults(){let sortedResults=[...results].sort((a,b)=>{if(a.startsWith("HTML Content:")&&b.startsWith("HTML Content:")) return a.localeCompare(b);if(a.startsWith("HTML Content:")) return -1;if(b.startsWith("HTML Content:")) return 1;return a.localeCompare(b)});sortedResults.forEach(result=>{document.write(result+"<br>")})}})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment