Skip to content

Instantly share code, notes, and snippets.

@krmax44
Last active November 22, 2017 09:11
Show Gist options
  • Save krmax44/8e7a89622b0fa9372fb305c7fab516cf to your computer and use it in GitHub Desktop.
Save krmax44/8e7a89622b0fa9372fb305c7fab516cf to your computer and use it in GitHub Desktop.
Mockify everything.
/*
Mockify text on the fly with this small script
How to use: Create a new bookmark in your browser, name it Mockify or something and as URL paste the following:
Click on the bookmark, enter your text and it will copy your mockified text to your clipboard.
*/
javascript:(function(){ var input = prompt("Mockify:", ""); var out = ""; for (i = 0; i < input.length; i++) { if (i % 2) { out += input[i].toUpperCase(); } else { out += input[i].toLowerCase(); } } var tbx = document.createElement('input'); document.body.appendChild(tbx); tbx.value = out; tbx.focus(); tbx.setSelectionRange(0, tbx.value.length); document.execCommand("copy"); document.body.removeChild(tbx); })();
/*
the source, if you need it for some reason
*/
function(){
// mock the text
var input = prompt("Mockify:", "");
var out = "";
for (i = 0; i < input.length; i++) {
if (i % 2) {
out += input[i].toUpperCase();
}
else {
out += input[i].toLowerCase();
}
}
// copy to clipboard
var tbx = document.createElement('input');
document.body.appendChild(tbx);
tbx.value = out;
tbx.focus();
tbx.setSelectionRange(0, tbx.value.length);
document.execCommand("copy");
document.body.removeChild(tbx);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment