Last active
October 19, 2024 11:36
-
-
Save indiamos/59ccb31d699ea64881776a236ac7424f to your computer and use it in GitHub Desktop.
Replaces an impossible-to-out-specify element style
This file contains hidden or 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
| (() => { | |
| const resizeObserver = new ResizeObserver(() => { | |
| const viewerBody = document.querySelectorAll("article.viewer__body"); | |
| viewerBody.forEach((node) => { | |
| node.setAttribute( | |
| "style", | |
| "color:#FADA5E!important;font-family:ScalaSansOT,Literata;line-height:2;font-size: 24px;" | |
| ); | |
| node.querySelectorAll("p").forEach((p) => p.removeAttribute("style")); | |
| node.querySelectorAll("p>span").forEach((span) => { | |
| if (span.style && span.style.fontStyle === "italic") { | |
| const italic = document.createElement("i"); | |
| italic.textContent = span.textContent; | |
| span.replaceWith(italic); | |
| } | |
| }); | |
| node | |
| .querySelectorAll("p>span") | |
| .forEach((span) => span.removeAttribute("style")); | |
| node | |
| .querySelectorAll("h2>b>span") | |
| .forEach((h2) => h2.removeAttribute("style")); | |
| node | |
| .querySelectorAll("h1>span") | |
| .forEach((h1) => h1.removeAttribute("style")); | |
| }); | |
| document.querySelectorAll("p+br").forEach((br) => br.remove()); | |
| document | |
| .querySelectorAll("p.MsoNormal") | |
| .forEach((p) => p.removeAttribute("class")); | |
| document.querySelectorAll("p").forEach((p) => { | |
| if (p.textContent.trim() === "") { | |
| p.remove(); | |
| } | |
| }); | |
| }); | |
| resizeObserver.observe(document.querySelector(".js-episode-viewer")); | |
| })(); | |
| // Minified and wrapped in a bookmarklet: | |
| // javascript:void(new ResizeObserver((()=>{document.querySelectorAll("article.viewer__body").forEach((e=>{e.setAttribute("style","color:#FADA5E!important;font-family:ScalaSansOT,Literata;line-height:2;font-size: 24px;"),e.querySelectorAll("p").forEach((e=>e.removeAttribute("style"))),e.querySelectorAll("p>span").forEach((e=>{if(e.style&&"italic"===e.style.fontStyle){const t=document.createElement("i");t.textContent=e.textContent,e.replaceWith(t)}})),e.querySelectorAll("p>span").forEach((e=>e.removeAttribute("style"))),e.querySelectorAll("h2>b>span").forEach((e=>e.removeAttribute("style"))),e.querySelectorAll("h1>span").forEach((e=>e.removeAttribute("style")))})),document.querySelectorAll("p+br").forEach((e=>e.remove())),document.querySelectorAll("p.MsoNormal").forEach((e=>e.removeAttribute("class"))),document.querySelectorAll("p").forEach((e=>{""===e.textContent.trim()&&e.remove()}))})).observe(document.querySelector(".js-episode-viewer"))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment