Created
September 30, 2021 05:57
-
-
Save forivall/57a5d60c99dee1b1ac6184f629592849 to your computer and use it in GitHub Desktop.
bookmarklet for improved printing
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
document.querySelectorAll('h1,h2,h3,h4,h5,h6').forEach((h) => { | |
var e = h.nextElementSibling, a = [h], d | |
e && a.push(e) | |
while (e && /H[0-6]/.test(e.tagName)) (e = e.nextElementSibling) && a.push(e) | |
if (a.length === 1) return | |
d = document.createElement('div') | |
d.style.display = 'inline-block' | |
h.replaceWith(d) | |
d.append(...a) | |
}) |
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:document.querySelectorAll("h1,h2,h3,h4,h5,h6").forEach((h=>{var e=h.nextElementSibling,a=[h],d;for(e&&a.push(e);e&&/H[0-6]/.test(e.tagName);)(e=e.nextElementSibling)&&a.push(e);1!==a.length&&((d=document.createElement("div")).style.display="inline-block",h.replaceWith(d),d.append(...a))})); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment