Skip to content

Instantly share code, notes, and snippets.

@JavaScript-Packer
JavaScript-Packer / animate-element-sin.js
Created July 7, 2015 08:36
Create animation in your web page with simple JavaScript. Simply moves up and down in a sine wave frequency. Live demo on http://jsfiddle.net/v7xr46jv/show/
document.write('<h1 id="x">WHAK.com</h1>');
var is = 0;
setInterval(function(r) {
r = document.getElementById("x");
r.style.position = "absolute";
r.style.top = 50 * Math.sin(is) + 80 + "px";
is += .05;
}, 1e3 / 30);
@JavaScript-Packer
JavaScript-Packer / zig-zag-vanity-scripting.js
Created July 7, 2015 06:02
Crazy chunker, silly, weird, unusual & odd obfuscation with Base64 and turning our JavaScript eval code into saw tooth shapes (see example with code) yet the code will still execute. Similar (new and improved version) to my Pyramid Packer on http://www.whak.ca/packer/
function chunky(a, start, cmd, longest, shortest, joiner, before, after) {
"" == start && (start = 9);
"" == cmd && (cmd = "btoa");
"" == longest && (longest = 75);
"" == shortest && (shortest = 1);
"" == before && (before = "//\\\n///\\\n///^\\\n//<->\\\n//WHAK\\\n//.COM/\\\n////////\\\n\\u0024 ='");
"" == after && (after = "eval(atob($));");
a = eval(cmd + "(a)");
for (var b = [], c = start; a; ) {
c > longest && (c = start);
@JavaScript-Packer
JavaScript-Packer / minify-html-function.js
Last active August 29, 2015 14:24
Very simple HTML minifier for http://www.whak.ca/HTMLZIP.htm - Hint: embed all external CSS and JavaScript for even more page loading perfomance, faster, quicker, less server calls, etc...
function kleen(e, r) {
return e.replace(/^ +| +$/g, "").replace(/^\t+|\t+$/g, "").replace(/^\r+|\r+$/g, "").replace(/^\n+|\n+$/g, "").replace(/\r?\n|\r|\x0a/g, "\n").replace(/(\r\n|\n|\r|\x0a)/gm, "\n").replace(/\n{2,}/g, "\n").replace(/\0/g, "\\0").replace(/\f{2,}/g, "\f").replace(/\v{2,}/g, " ").replace(/\/ +/g, "/").replace(/\t{2,}/g, " ").replace(/ {2,}/g, " ").replace(/\s\s+/g, " ").replace(/\s{2,}/g, "s").replace(/ *= */g, "=").replace(/<[^\S\f]*\![^\S\f]*--[^\S\f]*\[[^\S\f]*htmlclean-protect[^\S\f]*\][^\S\f]*--[^\S\f]*>([\s\S]*?)<[^\S\f]*\![^\S\f]*--[^\S\f]*\[[^\S\f]*\/[^\S\f]*htmlclean-protect[^\S\f]*\][^\S\f]*--[^\S\f]*>/gi, function(e, f) {
return r(f);
}).replace(/(<[^\S\f]*\?[^\S\f]*xml\b[^>]*?\?[^\S\f]*>)/gi, function(e, r) {
return o(r);
}).replace(/(<[^\S\f]*(\%|\?)[\s\S]*?\2[^\S\f]*>)/g, function(e, f) {
return r(f);
}).replace(/(<[^\S\f]*\?[^\S\f]*php\b[\s\S]*)/gi, function(e, f) {
return r(f);
}).replace(/(<[^\S\f]*jsp[^\S\f]*:[^>]*?>)/gi, function(e, f) {
@JavaScript-Packer
JavaScript-Packer / html-entities-encoder.js
Created July 5, 2015 23:58
My take on HTML entity encoding, escape HTML source code, make XML safe, etc. Thought I needed it for http://www.whak.ca/HTMLZIP.htm but didn't, so here it is the script:
function html_entities(me) {
return me.replace(/^\s+|\s+$/g, "").replace(/(\r\n|\n|\r|\x0a)/gm, "\n").replace(/\n{2,}/g, "\n").replace(/\n/g, "&#10;").replace(/\0/g, "&#00;").replace(/\t{2,}/g, "\t").replace(/\x27/g, "&#39;").replace(/\x22/g, "&#34;").replace(/ {2,}/g, " ").replace(/</g, "&#60;").replace(/>/g, "&#62;");
}
@JavaScript-Packer
JavaScript-Packer / vanity-scripting.js
Created July 3, 2015 11:47
Vanity scripting in JavaScript
var WHAK = new Object;
WHAK.com = 'alert("www.WHAK.com");';
WHAK.ca = 'alert("www.WHAK.ca");';
WHAK.us = 'alert("www.WHAK.us");';
eval(WHAK.com+WHAK.ca+WHAK.us);
@JavaScript-Packer
JavaScript-Packer / indexof-alternative.js
Created July 1, 2015 01:25
IE web browser often won't handle indexOf() command in JavaScript (Jscript is IE's engine or coding for Jscript.net), so here is an alternate function: http://jsfiddle.net/ccxqosxn/
function myIndexOf(a, b) {
var c, d, e = a.length, f = b.length;
for (c = 0; e > c; c++) {
for (d = 0; f > d && a[c + d] == b[d]; d++) ;
if (d == f) return c;
}
return -1;
}
//USAGE:
@JavaScript-Packer
JavaScript-Packer / base64-encode-decode.js
Created July 1, 2015 00:45
Perfect ATOB/BTOA alternatives (Base64 encoder/decoder) for JavaScript/Jscript.net Demo on http://jsfiddle.net/1okoy0r0/
function b2a(a) {
var c, d, e, f, g, h, i, j, o, b = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", k = 0, l = 0, m = "", n = [];
if (!a) return a;
do c = a.charCodeAt(k++), d = a.charCodeAt(k++), e = a.charCodeAt(k++), j = c << 16 | d << 8 | e,
f = 63 & j >> 18, g = 63 & j >> 12, h = 63 & j >> 6, i = 63 & j, n[l++] = b.charAt(f) + b.charAt(g) + b.charAt(h) + b.charAt(i); while (k < a.length);
return m = n.join(""), o = a.length % 3, (o ? m.slice(0, o - 3) :m) + "===".slice(o || 3);
}
function a2b(a) {
var b, c, d, e = {}, f = 0, g = 0, h = "", i = String.fromCharCode, j = a.length;
@JavaScript-Packer
JavaScript-Packer / pyramid-scheme-chunker.js
Created June 28, 2015 03:10
You can find the pyramid shaped JavaScript packer on www.whak.ca/packer/ so you can make your own! Live demo on http://jsfiddle.net/Lhzgddtn/
$='\
ZnVu\
Y3Rpb\
24gcmF\
uZG9tU2\
l0ZSgpe3\
ZhciBhPSJ\
odHRwOi8vd\
3d3LldIQUsu\
Y29tIGh0dHA6\
@JavaScript-Packer
JavaScript-Packer / encode-URL.html
Created May 20, 2015 02:14
3 ways to obfuscate links in HTML source code. Just the www part is encoded for example.
<a href="http://%77%77%77.scriptcompress.com/">ScriptCompress.com</a>
<a href="http://&#119;&#119;&#119;.scriptcompress.com/">ScriptCompress.com</a>
<a href="http://&#x77;&#x77;&#x77;.scriptcompress.com/">ScriptCompress.com</a>
Encoder/decoder on http://www.scriptcompress.com/30-encoders-in-1.htm
@JavaScript-Packer
JavaScript-Packer / unpacker.js
Last active August 29, 2015 14:21
Made an unpacker (still have to make the JavaScript Packer to compress to this format) that does not need to have assigned character list to match the mapped layout, instead it uses the number of replacement. Made this a while ago, but not long until you are using 2 bytes or more per replacement. The packer will do this with only repeated words …
var W,H,A,K='0("1 11 10.12");2("3 11 10.12");4("5 11 10.12");6.7="8 9 11 10.12";';H=13;
A='alert,HERE,prompt,THERE,confirm,EVERYWHERE,test,value,HELLO,WORLD,WHAK,From,com'[W='split'](',');
while(H--){if(K[H]){K=K[W](H).join(A[H])}}eval(K);
//unpacked
/*
alert("HERE From WHAK.com");
prompt("THERE From WHAK.com");
confirm("EVERYWHERE From WHAK.com");
test.value="HELLO WORLD From WHAK.com";