Skip to content

Instantly share code, notes, and snippets.

@caligin
Forked from stephskardal/jibberish
Last active July 24, 2019 18:58
Show Gist options
  • Save caligin/022e2996ab7691dc25ac to your computer and use it in GitHub Desktop.
Save caligin/022e2996ab7691dc25ac to your computer and use it in GitHub Desktop.
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;
});
})();
@caligin
Copy link
Author

caligin commented Aug 17, 2015

Forked to remove dependency from jQ (depends on document.querySelectorAll and Array.prototype.reduce instead).
Also modified to not change anything inside <head> or <script> or <style> tags contained in body.

@caligin
Copy link
Author

caligin commented Aug 17, 2015

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!

@lewisje
Copy link

lewisje commented Aug 18, 2015

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;});})();

@caligin
Copy link
Author

caligin commented Aug 18, 2015

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!

@caligin
Copy link
Author

caligin commented Aug 19, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment