copy and paste this in your browsers' console...
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
const walk = document.createTreeWalker(document.body, NodeFilter.SHOW_TEXT, null, false); | |
const delay = []; | |
while (true) { | |
const node = walk.nextNode(); | |
if (!node) break; | |
if (!node.textContent.trim()) continue; | |
const { parentElement } = node; | |
if (parentElement.tagName === 'STYLE') continue; | |
const { color, display } = getComputedStyle(parentElement); | |
if (display === 'inline') { | |
parentElement.style.backgroundColor = color; | |
} else { | |
const newNode = document.createElement('span'); | |
newNode.innerHTML = node.textContent; | |
newNode.style.backgroundColor = color; | |
delay.push([node, newNode]); | |
} | |
} | |
for (let [o, n] of delay) { | |
o.replaceWith(n); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment