Skip to content

Instantly share code, notes, and snippets.

@streetturtle
Last active August 10, 2017 02:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save streetturtle/045b606494a175a5aeee8012dc98abe6 to your computer and use it in GitHub Desktop.
Save streetturtle/045b606494a175a5aeee8012dc98abe6 to your computer and use it in GitHub Desktop.
function prepareForScreenshot(selector) {
var textElements = document.querySelectorAll(selector);
for (i = 0; i < textElements.length; ++i) {
textElements[i].innerHTML = randomiseString(textElements[i].textContent);
}
var imgElements = document.querySelectorAll('img');
for (i = 0; i < imgElements.length; ++i) {
imgElements[i].style.filter = 'blur(7px)';
}
}
function randomiseString(str){
var chars = " abcdefghijklmnopqrstuvwxyz0123456789";
var _str = str.replace(/[^-]/g,function(a){
return chars[Math.floor(Math.random() * chars.length)];
});
return _str;
}
prepareForScreenshot('span');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment