Last active
November 29, 2024 19:37
-
-
Save chris-castillo-dev/a366eac12e58ce8fa44be355063e2fa6 to your computer and use it in GitHub Desktop.
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 e=prompt("Please enter your selector",""),t=prompt("Would you like to label headings? (Y/N)"),o=prompt("Would you like lists hyphenated? (Y/N)"),l=prompt("Would you like to format tables as markdown? (Y/N)"),n=prompt("Would you like to inject link sources into the text? {Y/N)");null!=e&&function e(r){let a=document.querySelector(r);if(a&&window.open(document.location.href),!a){console.log("No element found with the provided selector.");return}document.querySelectorAll("script, img, picture, canvas, figure, video, iframe, embed, object, map, audio, button, svg, head, link, header, footer, google-cast-launcher, select, textarea, input, form, label, datalist, fieldset, legend, meter, optgroup, option, output, progress").forEach(e=>{"header"===e.tagName.toLowerCase()&&a.contains(e)||e.parentNode.removeChild(e)});let i=a.cloneNode(!0);document.body.innerHTML="",document.body.appendChild(i);let d=document.getElementsByTagName("*");for(let s=0;s<d.length;s++)if("a"===d[s].tagName.toLowerCase()){let g=d[s].getAttribute("href");if("y"===n.toLowerCase()&&g){let u=document.createTextNode(" (link: "+g+")");d[s].nextSibling?d[s].parentNode.insertBefore(u,d[s].nextSibling):d[s].parentNode.appendChild(u)}d[s].outerHTML=%27<a href="%27+g+%27">%27+d[s].innerHTML+"</a>"}else{let f=d[s].attributes;for(;f.length>0;)d[s].removeAttribute(f[0].name)}if("y"===o.toLowerCase()){let h=document.getElementsByTagName("li");for(let c=0;c<h.length;c++)h[c].textContent="- "+h[c].textContent}if("y"===l.toLowerCase()){let m=document.querySelectorAll("tr");for(let p=0;p<m.length;p++){let y=m[p].children;for(let C=0;C<y.length;C++)if(y[C].textContent="| "+y[C].textContent.trim()+" ","th"===y[C].nodeName.toLowerCase()&&0===p&&C===y.length-1){let N=document.createElement("tr");for(let b=0;b<y.length;b++){var x=document.createElement("td");x.textContent="|-------",N.append(x)}m[p].parentNode.insertBefore(N,m[p].nextSibling)}y.length>0&&(y[y.length-1].textContent+="|")}}if("y"===t.toLowerCase())for(let $=1;$<=6;$++){let L=document.getElementsByTagName("h"+$);for(let w=0;w<L.length;w++)L[w].textContent="[H"+$+"] "+L[w].textContent}}(e)}(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment