I am looking for some sort of complex mind-spinning (or not, if that's possible) way to use JavaScript to find all elements in the page that contain only some (not none, not all) content other than nested elements, and take said content and put it in a <span>.
The script must then take all elements that cannot contain content (<img>, anybody?) and those that contain no nested elements and return them like any of the getElement...()
functions.
This script must also delete elements that contain no content.
Example:
This page...
HTML Code:
...
<body>
Hello there. <em>Check this out.</em><strong></strong>
<table><tr>
<td></td><td><div>Furball: <img src="..."></div>Yay.</td>
<td><div>WOOPWOOPWOOP</div></td>
</tr></table>
</body>
</html>
Will be transformed into this page...
HTML Code:
...
<body>
<span>Hello there. </span><em>Check this out.</em>
<table><tr>
<td></td><td><div><span>Furball:</span> <img src="..."></div><span>Yay.<span></td>
<td><div>WOOPWOOPWOOP</div></td>
</tr></table>
</body>
</html>
And will be returned just like running document.getElementsByClass('lookyhere'); on...
HTML Code:
...
<body>
<span class="lookyhere">Hello there. </span><em class="lookyhere">Check this out.</em>
<table><tr>
<td></td><td><div><span class="lookyhere">Furball:</span> <img src="..." class="lookyhere"></div><span class="lookyhere">Yay.<span></td>
<td><div class="lookyhere">WOOPWOOPWOOP</div></td>
</tr></table>
</body>
</html>
Hope someone can help!
Bonus: Who can guess what I'm doing?
It involves Mr. Doob, Greasemonkey, April Fool's Day, and a comment made on the CENSORED posted at CENSORED by me under the name doggitydogs.
Bookmarks