-
-
Save caligin/022e2996ab7691dc25ac 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 size_amplification_factor = 1.1; | |
var possible = " ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; | |
Array.prototype.slice.call(document.querySelectorAll('body *:not(iframe)')).reduce(function(m, n){ return m.concat(Array.prototype.slice.call(n.childNodes)); },[]).filter(function(n) { | |
return n.nodeType === Node.TEXT_NODE && n.parentElement.nodeName !== 'SCRIPT' && n.parentElement.nodeName !== 'STYLE' && n.nodeValue.trim() != ''; | |
}).forEach(function(n) { | |
var new_content = ''; | |
for(var i = 0; i< (n.nodeValue.trim().length * size_amplification_factor); i++) { | |
new_content += possible.charAt(Math.floor(Math.random() * possible.length)); | |
} | |
n.nodeValue = new_content; | |
}); | |
})(); |
Also: useful test to see if layout breaks when content is bigger than expected. Tweak the size_amplification_factor
to increase the text size and see if your layout is up to the challenge!
I'm not making this a formal fork, but here it is all on one line and URL-encoded for browsers that don't like spaces in bookmarklets:
javascript:(function(){var%20size_amplification_factor=1.1,possible='%20ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';Array.prototype.slice.call(document.querySelectorAll('body%20*:not(iframe)')).reduce(function(m,n){return%20m.concat(Array.prototype.slice.call(n.childNodes));},[]).filter(function(n){return%20n.nodeType===3&&n.parentElement.nodeName!=='SCRIPT'&&n.parentElement.nodeName!=='STYLE'&&n.nodeValue.trim()!='';}).forEach(function(n){var%20new_content='',len=n.nodeValue.trim().length*size_amplification_factor,i=0;for(;i<len;i++)new_content+=possible.charAt(Math.floor(Math.random()*possible.length));n.nodeValue=new_content;});})();
Thanks, I'm working right now on making this a proper github repo instead of a gist so it's possible to PR and open issues, I'll include the URL-encoded version too!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Forked to remove dependency from jQ (depends on
document.querySelectorAll
andArray.prototype.reduce
instead).Also modified to not change anything inside
<head>
or<script>
or<style>
tags contained in body.