Skip to content

Instantly share code, notes, and snippets.

@JavaScript-Packer
JavaScript-Packer / multiple-replace-demo.js
Last active January 1, 2016 03:57
Multiple replacements VIA an array for find & replace terms.
var W,H,A,K;
W = '123456'[$='split']('');
H = 'test this WHAK com www for'[$](' ');
A = '2 is a 1 (1ed 6 3 2, 1 6 3 that), 1ing 6 5.3.4';
K = 0; for(K in W)A=A[$](W[K]).join(H[K]);
document['write'](A);
// this is a test (tested for WHAK this, test for WHAK that), testing for www.WHAK.com
@JavaScript-Packer
JavaScript-Packer / word-stats.js.html
Created July 26, 2015 16:13
Paste some text and get statistics on the words found in text. Demo on http://jsfiddle.net/dktvn13L/
<div id="wct_embed_counts">
<textarea id="wct_embed_input_text" rows="12">www.WHAK.com</textarea>
<div id="wct_embed_result">www.WHAK.com</div>
<div id="wct_powered_by">www.WHAK.com</div>
<script type="text/javascript">function wct_getWordStats(e) {
var r, a, _, c, d, s, u, t = [], n = e.trim();
t.num_character = e.trim().length;
r = n.split(/\s+/).join("");
t.num_character_wo_spaces = r.length, t.num_paragraph = 0, n.length > 0 && (t.num_paragraph = n.split(/\n+/).length);
a = n.replace(/(\w)[-_'](\w)/gi, "$10$2");
@JavaScript-Packer
JavaScript-Packer / html.entity.safe.escape.js
Last active December 23, 2018 11:24
Turned/reversed the unpacker for WHAK compression algorithm and made it into a HTML entities encoder - http://www.whak.ca/packer/JavaScript.htm
var W,H,A,K;
H ="&amp; &lt; &gt; &#34; &#10; &#39;"[$="split"](" ");
A ="&<>\"\n'";W='<script>alert("www.WHAK.com");<\/script>';
K =0;for(K in A)W=W[$](A[K]).join(H[K]);alert(W);
@JavaScript-Packer
JavaScript-Packer / smiley-shaped.js
Last active August 29, 2015 14:26
http://www.whak.ca/packer/smilies.htm Working on a script generator that will turn JavaScript source codes into silly shapes, here is a sample
var WHAK=
'var C="charCodeAt",G=eval,'+
'I="indexOf",Q="charAt",U=32768,M=G('+
'"Math.pow");_$={_:"WHAK+com/PaCker=BDEFGIJL'+
'MNOQRSTUVXYZbdfghijlnpqstuvwxyz0123456789",_f:Str'+
'ing.fromCharCode,$:function(r){if(null==r)return"";v'+
'ar a,e,t,o,h,c,f="",n=0,i=0,d=_$._f;for(r=r.replace(/[^A-'+
'Za-z0-9+/=]/g,"");i<r.length;)e=_$._[I](r[Q](i++)),t=_$._[I]('+
'r[Q](i++)),h=_$._[I](r[Q](i++)),c=_$._[I](r[Q](i++)),e=e<<2|t>>4,'+
't=(15&t)<<4|h>>2,o=(3&h)<<6|c,0==n%2?(a=e<<8,64!=h&&(f+=d(a|t)),64!'+
@JavaScript-Packer
JavaScript-Packer / base64-encoder-utf.js
Created July 31, 2015 05:18
Base64 encoder with UTF-8 encoding - Base64 Button function for http://www.whak.ca/packer/LZW(HAK).htm
function b2a(r) {
function utf(r) {
var t, e, o;
for (r = r.replace(/\r\n/g, "\n"), t = "", e = 0; e < r.length; e++) o = r.charCodeAt(e),
128 > o ? t += String.fromCharCode(o) :o > 127 && 2048 > o ? (t += String.fromCharCode(192 | o >> 6),
t += String.fromCharCode(128 | 63 & o)) :(t += String.fromCharCode(224 | o >> 12),
t += String.fromCharCode(128 | 63 & o >> 6), t += String.fromCharCode(128 | 63 & o));
return t;
}
var t, a, h, e, o, c, n = "", C = 0, i = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
@JavaScript-Packer
JavaScript-Packer / base64-decoder-utf.js
Created July 31, 2015 05:20
Base64 decoder with UTF-8 decode of encoded ascii - unBase64 Button function for http://www.whak.ca/packer/LZW(HAK).htm
function a2b(r) {
function utf(r) {
for (var t = "", e = 0, o = c1 = c2 = 0; e < r.length; ) o = r.charCodeAt(e), 128 > o ? (t += String.fromCharCode(o),
e++) :o > 191 && 224 > o ? (c2 = r.charCodeAt(e + 1), t += String.fromCharCode((31 & o) << 6 | 63 & c2),
e += 2) :(c2 = r.charCodeAt(e + 1), c3 = r.charCodeAt(e + 2), t += String.fromCharCode((15 & o) << 12 | (63 & c2) << 6 | 63 & c3),
e += 3);
return t;
}
var t, X = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", e, o, a, h, n = "", c = 0;
for (r = r.replace(/[^A-Za-z0-9\+\/\=]/g, ""); c < r.length; ) t = X.indexOf(r.charAt(c++)),
@JavaScript-Packer
JavaScript-Packer / lzw-encoder-compress.js
Created July 31, 2015 05:45
LZW encoder, old compression used in GIF images. Also the function is used on http://www.whak.ca/packer/LZW(HAK).htm
function lzw_encode(u) {
var r, a, n = {}, t = (u + "").split(""), e = [], i = t[0], o = 256;
for (a = 1; a < t.length; a++) r = t[a], null != n[i + r] ? i += r :(e.push(i.length > 1 ? n[i] :i.charCodeAt(0)),
n[i + r] = o, o++, i = r);
for (e.push(i.length > 1 ? n[i] :i.charCodeAt(0)), a = 0; a < e.length; a++) e[a] = String.fromCharCode(e[a]);
return e.join("");
}
@JavaScript-Packer
JavaScript-Packer / how-many-bytes-in-string.js
Last active August 29, 2015 14:26
Pass any string of characters (binary, ascii, Chinese, etc) and it will return the bytes (formatted like 1,000,000) of characters (not just the character count, some characters are more than one byte). Used on http://www.whak.ca/packer/JavaScript.htm
function bytez(n) {
return n = unescape(encodeURI(n)).length, ("" + n).split(/(?=(?:\d{3})+(?:\.|$))/g).join(",");
}
@JavaScript-Packer
JavaScript-Packer / test-eval-edit-JavaScript.js
Created July 31, 2015 06:01
Eval for a JavaScript snippet or source codes in a new window (my way to sandbox away from any page). This is the function used for TEST JS button on http://www.whak.ca/packer/JavaScript.htm
function testJS(n, r) {
r = window.open("about:blank", "", "width=999,height=666");
r.document.write('\
<title>WHAK.com</title>\
<body>\
<i>\
<font size="2" color="blue">\
<u title="Click here to demonstrate the code (blue text) used to change this textarea/text box. Might come in handy for replacing a alert or document.write when you want to see results from your script." onclick="test.value=&quot;Hello World&quot;;">\
test.value="Hello World";\
</u>\
function decode_ascii85(a) {
var c, d, e, f, g, h = String, l = "length", w = 255, x = "charCodeAt", y = "slice", z = "replace";
for ("<~" === a[y](0, 2) && "~>" === a[y](-2), a = a[y](2, -2)[z](/\s/g, "")[z]("z", "!!!!!"),
c = "uuuuu"[y](a[l] % 5 || 5), a += c, e = [], f = 0, g = a[l]; g > f; f += 5) d = 52200625 * (a[x](f) - 33) + 614125 * (a[x](f + 1) - 33) + 7225 * (a[x](f + 2) - 33) + 85 * (a[x](f + 3) - 33) + (a[x](f + 4) - 33),
e.push(w & d >> 24, w & d >> 16, w & d >> 8, w & d);
return function(a, b) {
for (var c = b; c > 0; c--) a.pop();
}(e, c[l]), h.fromCharCode.apply(h, e);
}