Skip to content

Instantly share code, notes, and snippets.

@shubhamsolanki0x
Forked from jhaddix/endpoints bookmarklet
Created October 20, 2024 09:22
Show Gist options
  • Save shubhamsolanki0x/9e21727c37d1d3ccafc9bbba1f02e7c0 to your computer and use it in GitHub Desktop.
Save shubhamsolanki0x/9e21727c37d1d3ccafc9bbba1f02e7c0 to your computer and use it in GitHub Desktop.
javascript:(function(){function e(){var e=document.createElement("div");e.style.position="fixed",e.style.top="50%",e.style.left="50%",e.style.transform="translate(-50%, -50%)",e.style.backgroundColor="#001f3f",e.style.color="white",e.style.fontFamily="Arial, sans-serif",e.style.padding="20px",e.style.boxShadow="0 0 10px rgba(0,0,0,0.5)",e.style.zIndex="9999",e.style.maxHeight="80%",e.style.maxWidth="80%",e.style.overflowY="auto";var t=document.createElement("button");t.innerText="Close",t.style.position="sticky",t.style.top="0",t.style.backgroundColor="#ff4136",t.style.color="white",t.style.border="none",t.style.padding="10px",t.style.cursor="pointer",t.onclick=function(){document.body.removeChild(e)},e.appendChild(t);var n=document.createElement("div");n.id="endpointContainer",n.innerHTML="<h2 style='color:white;'>Endpoints</h2>",e.appendChild(n);var o=document.createElement("div");o.id="paramContainer",o.innerHTML="<h2 style='color:white;'>Endpoints with Parameters</h2>",e.appendChild(o);var a=document.createElement("div");a.id="commentContainer",a.innerHTML="<h2 style='color:white;'>Comments</h2>",e.appendChild(a),document.body.appendChild(e)}function t(){var e=document.getElementById("endpointContainer");e.innerHTML="<h2 style='color:white;'>Endpoints</h2>";var t=document.getElementById("paramContainer");t.innerHTML="<h2 style='color:white;'>Endpoints with Parameters</h2>";var n=document.getElementById("commentContainer");n.innerHTML="<h2 style='color:white;'>Comments</h2>",r.forEach(function(e){var t=new URL(e,window.location.origin).href;if(e.includes("?")){var n=document.createElement("table");n.style.width="100%",n.style.marginBottom="10px",n.style.borderCollapse="collapse";var o=document.createElement("thead"),a=document.createElement("tr"),l=document.createElement("th");l.innerText="Parameter",l.style.border="1px solid white",l.style.padding="5px";var d=document.createElement("th");d.innerText="Value",d.style.border="1px solid white",d.style.padding="5px",a.appendChild(l),a.appendChild(d),o.appendChild(a),n.appendChild(o);var c=document.createElement("tbody"),i=new URLSearchParams(e.split("?")[1]);i.forEach(function(e,t){var n=document.createElement("tr"),o=document.createElement("td");o.innerText=t,o.style.border="1px solid white",o.style.padding="5px";var a=document.createElement("td");a.innerText=e,a.style.border="1px solid white",a.style.padding="5px",n.appendChild(o),n.appendChild(a),c.appendChild(n)}),n.appendChild(c);var s=document.createElement("div"),m=document.createElement("a");m.href=t,m.innerText=t,m.style.color="white",m.style.display="block",m.style.marginBottom="10px",s.appendChild(m),s.appendChild(n),paramContainer.appendChild(s)}else{var s=document.createElement("div"),m=document.createElement("a");m.href=t,m.innerText=t,m.style.color="white",m.style.display="block",m.style.marginBottom="10px",s.appendChild(m),endpointContainer.appendChild(s)}}),comments.forEach(function(e){var t=document.createElement("div");t.innerText=e,t.style.border="1px solid white",t.style.padding="5px",t.style.marginBottom="10px",commentContainer.appendChild(t)})}e();var n=document.getElementsByTagName("script"),o=/(?<=(\"|\'|\%60))\/[a-zA-Z0-9_?&=\/\-\#\.]*(?=(\"|\'|\%60))/g,c=/<\!--[\s\S]*?-->/g;const r=new Set,l=new Set;for(var a=0;a<n.length;a++){var d=n[a].src;d&&fetch(d).then(function(e){return e.text()}).then(function(e){var t=e.matchAll(o);for(let e of t)r.add(e[0]);var n=e.matchAll(c);for(let e of n)l.add(e[0])}).catch(function(e){console.log("An error occurred: ",e)})}var i=document.documentElement.outerHTML,m=i.matchAll(o),s=i.matchAll(c);for(const e of m)r.add(e[0]);for(const e of s)l.add(e[0]);setTimeout(t,3e3)})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment