Skip to content

Instantly share code, notes, and snippets.

@JavaScript-Packer
JavaScript-Packer / smiley-obfuscator.js
Created May 1, 2015 11:29
Here is a complete web app called The Smiley Face Script Generator I made. It takes your JavaScript source code and then encodes it with smiley faces. It packs it up with the decoder built in so it is auto running code still. A demo of the generator on http://jsfiddle.net/tppzgm5e/show/
function smilies(e){var r,n,t,R='\x72\x65\x70\x6c\x61\x63\x65',a="";
for(r=0;r<e.length;r++)n=e.\u0063\u0068\u0061\u0072\u0043\u006f\u0064\u0065\u0041\u0074(r).\u0074\u006f\u0053\u0074\u0072\u0069\u006e\u0067(4),t=n[R](/0/g,":(")[R](/1/g,":)")[R](/2/g,":P")[R](/3/g,":D"),a+=t+" ";
var p1="\x76\x61\x72\x20\x7a\x3d\x27\\\n\\\n",p3="\\\n\\\n',u=\\u0052\\u0065\\u0067\\u0045\\u0078\\u0070,\\u0072,\\u006e,\\u0074,\\u0061='',\\u006f=\\u007a['\\x73\\x70\\x6c\\x69\\x74'](' ');for(\\u0072=0;\\u0072<\\u006f['\\x6c\\x65\\x6e\\x67\\x74\\x68'];\\u0072++)\\u006e=\\u006f[\\u0072],\\u0074=\\u006e[x='\\x72\\x65\\x70\\x6c\\x61\\x63\\x65'](u(':\\\\(','g'),'0')[x](u(':\\\\)','g'),'1')[x](/:P/g,'2')[x](/:D/g,'3'),\\u0061+=\\u0053\\u0074\\u0072\\u0069\\u006e\\u0067['\\x66\\x72\\x6f\\x6d\\x43\\x68\\x61\\x72\\x43\\x6f\\x64\\x65'](\\u0070\\u0061\\u0072\\u0073\\u0065\\u0049\\u006e\\u0074(\\u0074,4));\\u0065\\u0076\\u0061\\u006c(\\u0061[x](/\\0/g,''));\x2f\x2a\x20\x77\x77\x77\x2e\x57\x48\x41\x4b\x2e\x63\x61\x20\x2a\x2f";
\u0073\u006d\u0
@JavaScript-Packer
JavaScript-Packer / replace-all.js
Created May 1, 2015 07:26
My favorite function for search and replace in JavaScript
function replaceAllExact(str,find,replace){
return str.split(find).join(replace)
};
alert(replaceAllExact('Google VS. www.google.com','google','seekfreak'));
//minified
//function i(i,a,e){return i.split(a).join(e)}alert(i("Google VS. www.google.com","google","seekfreak"))
@JavaScript-Packer
JavaScript-Packer / bookmarklet-collection.txt
Created May 1, 2015 06:59
Largest collection of bookmarklet tools on the internet... A little of everything...
http://jsfiddle.net/nh8e22r4/show/ - 2,500 bookmarklets 
@JavaScript-Packer
JavaScript-Packer / wow.js
Created May 1, 2015 00:01
Crazy ways to obfuscate JavaScript functions/commands
// I still can't get over how I can obfuscate alert(69) to
\u0061\u006c\u0065\u0072\u0074(69)
// and it will still work (in JavaScript)
@JavaScript-Packer
JavaScript-Packer / string2binary.js
Created April 30, 2015 23:55
Convert a string of text to Base2 binary (with spacing as delimiter)
var Δ='JavaScript Packer';
function str2bin(Δ, w, o) {
w = [];
for (o in Δ) {
w.push(Δ.charCodeAt(o).toString(2));
}
return w.join(" ");
}
alert(str2bin(Δ));
@JavaScript-Packer
JavaScript-Packer / blobity.js
Created April 30, 2015 18:51
Automatic downloading JavaScript source code with blobs
// click on generated href link dynamically created and attached to page
var Δ="script.js",data="alert('THIS IS A TEST');",d="download",$="setAttribute",_=document,
r=new Blob([data],{type:"text/plain;charset=utf8;"}),e=_.createElement("a");
void 0!==e[d]?(e[$]("href",window.URL.createObjectURL(r)),e[$](d,Δ)):e[$]("href","http://www.whak.com"),
e.click(),_.body.appendChild(e);
//automatic downloader, download pops up right after page load
@JavaScript-Packer
JavaScript-Packer / blobify.js
Created April 30, 2015 18:45
Make a JavaScript source code into a download link using blobs. Click link to download.
//make a javascript source code downloadable by blob
var name="script.js",data="alert('THIS IS A TEST');",d="download",$="setAttribute",_=document,
r=new Blob([data],{type:"text/plain;charset=utf8;"}),e=_.createElement("a");
void 0!==e[d]?(e[$]("href",window.URL.createObjectURL(r)),
e[$](d,name)):e[$]("href","http://www.whak.com"),e.innerHTML="Download",_.body.appendChild(e);
@JavaScript-Packer
JavaScript-Packer / download-blob.js
Last active August 29, 2015 14:20
Turn a string into a downloadable blob link to click on for download.
//create blob link for downloading data
var name = "YourFile.txt", data = "THIS IS JUST A TEST", d = "download", $ = "setAttribute", _ = document, r = new Blob([ data ], {
"type": "text/plain;charset=utf8;"
}), e = _.createElement("a");
void 0 !== e[d] ? (e[$]("href", window.URL.createObjectURL(r)), e[$](d, name)) : e[$]("href", "http://www.whak.com"),
e.innerHTML = "Download", _.body.appendChild(e);
@JavaScript-Packer
JavaScript-Packer / bracket-notation.js
Created April 30, 2015 16:06
JavaScript simple golf coding example taking advantage of Bracket Notation using online golfing tool http://www.scriptcompress.com/golf.htm
//BEFORE: below is 394 byte sample that we want to make smaller with one simple technique
/*
var r={d4:function(){return Math.floor(4*Math.random())+1},
d6:function(){return Math.floor(6*Math.random())+1},d8:function(){return Math.floor(8*Math.random())+1},
d10:function(){return Math.floor(10*Math.random())+1},d12:function(){return Math.floor(12*Math.random())+1},
d20:function(){return Math.floor(20*Math.random())+1}};alert("rolling D4 : "+r.d4()),alert("rolling D20 : "+r.d20());
*/
//AFTER: 340 bytes, over 50 bytes saved
@JavaScript-Packer
JavaScript-Packer / base64-compression.js
Created April 30, 2015 14:19
Sick of Base64 encoding making everything bigger? We have come up with a free tool on www.scriptcompress.com to help compress and pack to a self extracting/running JavaScript. We originally made the tool for compressing DNA code sequences, but discovered it works well with many types of encrypted and encoded type stuff :)
// Base64 encoing sucks, it makes everything 33% bigger. But, we are going to make it smaller using
// tools on http://www.scriptcompress.com/DNA-Packer.htm
//demo script using 5.5KB Base64 encoding of 4KB of HTML code
pack='PGgyPkZyZWUgVG9vbHMgRm9yIFByb2dyYW1tZXJzOjwvaDI+CjxoND48YSBocmVmPSJodHRwO\
i8vd3d3LnNjcmlwdGNvbXByZXNzLmNvbS9KYXZhU2NyaXB0LVBhY2tlcnMuaHRtIj4yMCBQYWNrZXJz\
IEluIDEgQXBwPC9hPjwvaDQ+CjxoND48YSBocmVmPSJodHRwOi8vd3d3LnNjcmlwdGNvbXByZXNzLmN\
vbS9QSFAtUGFja2VyLmh0bSI+UEhQIFNvdXJjZSBDb2RlIFBhY2tlcnM8L2E+PC9oND4KPGg0PjxhIG\
hyZWY9Imh0dHA6Ly93d3cuc2NyaXB0Y29tcHJlc3MuY29tL1RleHQtVG8tSmF2YVNjcmlwdC5odG0iP\
lRleHQgUGFja2VyPC9hPjwvaDQ+CjxoND48YSBocmVmPSJodHRwOi8vd3d3LnNjcmlwdGNvbXByZXNz\