Skip to content

Instantly share code, notes, and snippets.

@JavaScript-Packer
JavaScript-Packer / HTML-minify-cleaner.js
Created January 1, 2016 04:08
Minify HTML, it can be harsh, so test the results.
function minhtm(r, R) {
R = "replace";
return r[R](/>(\n| | )*</g, "><")[R](/[a-z-]+=""/g, "")[R](/"([^ ]*)"/g, "$1")[R](/<\/li>/, "");
}
var minifyHtml = function() {
var r = /<(pre|style|script(?![^>]*?src))[^>]*>[\s\S]*?<\/\1>/gi, e = /("|')(?:\\\1|[^\1])*?\1/g, n = /__str(\d+)__/g, t = /<preserved>/g, c = /<!--(?!\s*?\[\s*?if)[\s\S]*?-->/gi, s = "", i = /(?:\s+=|=\s+)(?=[^<]*>)/g, p = "=", a = /\s*>/g, l = ">", u = /\s+(?=[^<]*>)/g, g = " ", o = />\s+</g, f = "><", _ = /(<\w+ )([^>]*)/g, v = function(r, e, n) {
return e + n.split(" ").sort().join(" ");
}, m = /<.*?class=("|')([^\1]*)\1/gi, h = function(r, e, n, R) {
var t = n.split(/\s\s*/g).sort().join(" ");
@JavaScript-Packer
JavaScript-Packer / HTML-character-code-encoder.htm
Created December 23, 2015 23:53
See the HTML coding used to hide all the JavaScript code, titles, and other data in this simple HTML code? Well it is the code to run to encode your own text to HTML code.
<textarea title="&#69;&#110;&#99;&#111;&#100;&#101;&#32;&#101;&#109;&#97;&#105;&#108;&#47;&#108;&#105;&#110;&#107;&#115;&#32;&#40;&#104;&#101;&#114;&#101;&#41;&#32;&#98;&#101;&#102;&#111;&#114;&#101;&#32;&#112;&#111;&#115;&#116;&#105;&#110;&#103;&#44;&#32;&#98;&#105;&#112;&#97;&#115;&#115;&#32;&#115;&#101;&#99;&#117;&#114;&#105;&#116;&#121;&#32;&#99;&#104;&#101;&#99;&#107;&#115;&#32;&#111;&#110;&#32;&#109;&#111;&#115;&#116;&#32;&#100;&#97;&#116;&#105;&#110;&#103;&#32;&#115;&#105;&#116;&#101;&#115;&#32;&#116;&#111;&#32;&#97;&#108;&#108;&#111;&#119;&#32;&#121;&#111;&#117;&#32;&#116;&#111;&#32;&#112;&#111;&#115;&#116;&#32;&#108;&#105;&#110;&#107;&#115;&#32;&#97;&#110;&#100;&#32;&#101;&#109;&#97;&#105;&#108;&#32;&#97;&#100;&#100;&#114;&#101;&#115;&#115;&#32;&#116;&#111;&#32;&#108;&#105;&#118;&#101;&#32;&#99;&#104;&#97;&#116;&#115;&#44;&#32;&#112;&#114;&#111;&#102;&#105;&#108;&#101;&#115;&#32;&#97;&#110;&#100;&#32;&#109;&#101;&#115;&#115;&#97;&#103;&#105;&#110;&#103;&#32;&#115;&#101;&#114;&#118;&#105;&#99;&#101;&#
@JavaScript-Packer
JavaScript-Packer / character-counter.htm
Created December 18, 2015 10:22
Character counter I threw together so I can see exactly how many chars are used in a chunk of text data
<head><title>Character Counter</title></head><body onclick="whak();">
<h1><a href="http://www.whak.ca">WHAK.ca</a>'s Character Counter</h1>
<textarea onkeyup="whak();" oninput="whak();" onchange="whak();" onfocus="whak();" onscroll="whak();" onclick="whak();" onkeydown="whak();"
id="whak" width="728" height="450" ondblclick="whak();" style="width:728px;height:300px"
placeholder="Type here to find out how many characters are used.&#10;&#10;You can also paste a clump of text in this box.&#10;&#10;www.ScriptCompress.com"
onmouseover="whak();this.select()"></textarea>
<h1 id="count"></h1>
<script>
function whak() {
function n(n) {
var W,H,A,K,com;for(W='̲͖͈̯͕̺͉͈͓̭͈̰͉͇̘̺͕̱̎͗͑̎̀\n͙̭͓͚̱̮͔̺͕̱͔͈̱͚͓͓̭̙̘̘̜̗̘̙̙̙̠͚̱̮͔̺͕̱͔̥̩̹͕͕͍͚͚͚̞̯͉͇̎̎̔̎̎ͤ͗͑̒̈́̇̎ͫͬ̎ͬ̎͆̎͋̎ͦ͆̾̾ͨ͛̎ͨ̎̇̈́͊̎̔̎͒̏̈́̈́̓ͫͤͮ̓͒̕̚\n̛͚̱̮͔̺͕̱͔̥̩̹͕͕͍͚͚͚̺̮̱̙̹͖͇͍̱͓͈̱͕͚̱̮͔̺͕̱͔̥̩̹͕͕͍͚͚͚̙͓͉̺̱̯͉͇͚̱̮͔̺͕̱͔̥̩̹͕͕͍͚͚͚͉̺̮̱͔̯͉͇͚̱̮͔̺͕̱͔̥̩̹͕͕͍͚͚͚̭̼̱̱͇̱̯͉͇͚̱̮͔̺͕̱͔̥̩̹͕͕͍͚͚͚͉͉̮̘̺̳͈͔̯͉͇͋̎̔̎̅̏̈́̈́̓ͥ̓̅̒͌̎̔̎̅̏̈́̈́̓̓̅̒̃̎̔̎̅̏̈́̈́̓ͫ͂ͥ̓̅̒̂̎̔̎̅̏̈́̈́̓̾͂ͤ͂̾̓̅̒̌̎̔̎͒̏̈́̈́̓ͥ̓͒̕ͅͅͅͅͅ\n͚̱̮͔̺͕̱͔̥̩̹͕͕͍͚͚͚̘̱̱̼͓̱̭̼̯͉͇͐̎̔̎̅̏̈́̈́̓ͩ̓̅\n̙̘̘̜̗̙̙̠̈́̈́̎ͫͬ̎ͬ̎͆̎͌͛ͧ̎ͦ͆̾̾ͨ͛̎ͨ̚\ǹ͚̱̮͔̺͕̱͔̥̩̹͕͕͍͚͚͚͔̱͓̼̯͉͇͚̱̮͔̺͕̱͔̥̩̹͕͕͍͚͚͚͉̺̮̱̝̱͓͔̱̯͉͇͚̱̮͔̺͕̱͔̥̩̹͕͕͍͚͚͚͉̺̮̱̘̱̭͓̯̹̯͉͇͚̱̮͔̺͕̱͔̥̩̹͕͕͍͚͚͚̘̺͓̘̱̱̼̯͉͇͚̱̮͔̺͕̱͔̥̩̹͕͕͍͚͚͚̙̟̙̯͉͇͚̱̮͔̺͕̱͔̥̩̹͕͕͍͚͚͚̯͉͇͚̱̮͔̺͕̱͔̥̩̹͕͕͍͚͚͚̱͓̰̲͖̯͉͇͚̱̮͔̺͕̱͔̥̩̹͕͕͍͚͚͚̭͈̘̺̳͈̱͈̱͓̭͕͉͓̯͉͇̎̔̎̅̏̈́̈́̓ͬ͂ͤ͂ͭ̓̅̒́̎̔̎̅̏̈́̈́̓ͫͥ̓̅̒̋̎̔̎̅̏̈́̈́̓ͫͥ̓̅̒͋͊̎̔̎̅̏̈́̈́̓̓̅̒͋͋̎̔̎̅̏̈́̈́̓͌ͬͦ̓̅̒͋͌̎̔̎̅̏̈́̈́̓͋̃ͮͪ̓̅̒͋̃̎̔̎̅̏̈́̈́̓͛̓̅̒͋̂̎̔̎̅̏̈́̈́̓ͩͪ̓̅̒̈́̇̕̕̚ͅͅͅͅͅ\n̙̘̘̜̗ͫͬ̎ͬ̎͆\ñ̗̙ͧ̎ͦ͆̾̾ͨ͛\n̙̠ͨ̚\ṅ͚̱̮͔̺͕̱͔̥̩̹͕͕͍͚͚͚͉̺̮̱͔͉͓̳͚̱̮͔̺͕̱͔̥̩̹͕͕͍͚͚͚̝̺͓͕͖̭͉̺̮̱̯͉͇͚̱̮͔̺͕̱͔̥̩̹͕͕͍͚͚͚̘̯͓̺͍͕͉͇͍͓̱͔͔̯͉͇̈́͋̌̎̔̎̅̏̈́̈́̓ͫ͂ͥ̓̅̒͋͐̎̔̎̅̏̈́̈́̓ͫͥ̓̅̒͋̀̎̔̎̅̏̈́̈́̓ͦ̓̅̕̕ͅͅͅͅͅ\n͚̱̮͔̺͕̱͔̥̩̹͕͕͍͚͚͚͉̺̮̱͔̯͉͇͚̱̮͔̺͕̱͔̥̩̹͕͕͍͚͚͚͋́̎̔̎̅̏̈́̈́̓ͫ͂ͥ̓̅̒͋̋̎̔̎̅̏̈́̈́̓̾̕ͅͅ
@JavaScript-Packer
JavaScript-Packer / cursor.js
Last active November 26, 2015 00:24
This is a 3,180 byte cursor (penis.cur) of a penis compressed (encoded Base64) to 1,600 bytes, it also has JavaScript code to inject it as CSS to the page.
var WHAK_com = function(u) {
var a, s, c, n = {}, t = (u + "").split(""), e = t[0], r = e, i = [ e ], o = 256;
for (s = 1; s < t.length; s++) c = t[s].charCodeAt(0), a = 256 > c ? t[s] :n[c] ? n[c] :r + e,
i.push(a), e = a.charAt(0), n[o] = r + e, o++, r = a;
return i.join("");
}(decodeURIComponent(escape(function(a) {
var b, c, d, e = {}, f = 0, g = 0, h = "", i = String.fromCharCode, j = a.length;
for (b = 0; 64 > b; b++) e["WHAK.com/paCker NOT^2~BIG_[JS-RULEZ] (@$%,#&X;){MDPV!*9405+1638}=".charAt(b)] = b;
for (c = 0; j > c; c++) for (b = e[a.charAt(c)], f = (f << 6) + b, g += 6; g >= 8; ) ((d = 255 & f >>> (g -= 8)) || j - 2 > c) && (h += i(d));
return h;
@JavaScript-Packer
JavaScript-Packer / ZIP-marklet.js
Last active September 9, 2015 23:09
Bookmarklet to compress web page you are on to a downloadable ZIP compressed file for archiving. Drag & drop marklet link on http://marklets.com/ZIP.aspx Made by www.scriptcompress.com
javascript:var%20WHAK_com=atob('QlpoOTFBWSZTWeYMnOsAGyr/gD8ARAB3////v////7////9gHU99VRe99b40Pt755n2Mdzjrm+8X3djLQe7uKK2affXjo5190h73xlmbtp3z7vp9u9vZM6qj3ufU9A++y2lvt9q8+89r3WW27m6ddzd776D7fXwaEmgABGIZNAjE0MjSYTTATQyNUep5NNNTynqANTITACYImpqp5T1PU9TJoZD1PUeiNkjT1NqNAAAABqaZMQE0JMQFM1JsU2obRGh4UGh5TxQA00AADTIQgKeg1MgEnok9T0TaaGEyBqPIIxDIeoABhIkRoI0hpPQNJgDU0eo1PEp6AyNJvUnpp6j1GgZIPJMJIiaABBT1MGUp+ADU1P1U2nqGTU2mjCGjTaNKMGp6jNhmqlGf5Z8gRD7fur9+YQDRUfoL4rU//JP2uVutQPwkQ9P399QV1luOqoaZ8K++8a2Eva0PWHBkI7JOJyRNnHhhSyOsSM+VcoAHD2sEgyevrH9ncsX0B/Hafyg/Cm8Jh/BQ3ooLi7zZ8F/UpREKQNKTUWKww1h+jYAuj4rzku0CRm5VfSQpZRocj8aw+MXjRaDyABiIm0hErHt0uj0yt4ffyh7MFtN4x873OU3p+91G9VKKV8FHNKI1HNU9lhNo7bPRfazQ3Knri0ObDC0/5BBdPlPuYX2JgEMQR9kiQREIZJyxzX+XKIFNgMTHDy/yZHvPQzq2+Z6hqMzB1j55acb8UZVvjP+kpeGK6myGUdd4I1tmdrVphmdyaia/x2wp1HTLq9JIZ86s91cY1UwKaByoYzedwytOxIknUbqyoHSs99uDXqXdCtfSXOLVA6j8xhYFAzN0gI7vHyZpsBu4oJcx0INgRNN7aOmASgZFWd20kP+EhDRsaFRaBiroIcUimtXm4tcbZGWYLR2cBiWBG6q6rY4kXgAdxO4jbJyVAEsxvn858S+cvF4Qnp5xIRL/ZGJ3n5HK2FgNgYiy/parxFBR
@JavaScript-Packer
JavaScript-Packer / Uint8Array2string.js
Created August 21, 2015 18:32
Uint8Array to String
function uintToString(uintArray) {
var encodedString = String.fromCharCode.apply(null, uintArray),
decodedString = decodeURIComponent(escape(encodedString));
return decodedString;
}
@JavaScript-Packer
JavaScript-Packer / video2canvas.htm
Last active August 29, 2015 14:27
HTML5 Video To Canvas Using JavaScript - When you play the video, you will see another copy in the canvas element. MP4 video in embedded VIA dataURI scheme. Nothing special, but soon I want to capture each frame as animated GIF, just one of the steps... Live demo on http://codepen.io/samples/pen/yNdRKQ
<script>
function draw(e, t, a, n, d) {
if (e.paused || e.ended) return !1;
a.drawImage(e, 0, 0, n, d);
var r = a.getImageData(0, 0, n, d);
r.data, t.putImageData(r, 0, 0), setTimeout(function() {
draw(e, t, a, n, d);
}, 0);
}
document.addEventListener("DOMContentLoaded", function() {
@JavaScript-Packer
JavaScript-Packer / encode-non-ascii.js
Created August 21, 2015 14:06
Only encode codepoints 127 and up. 127 to 255 get encoded to hexdecimal and 256 to 65536 get encoded to unicode
String.prototype.replaceWithUtf8 = function() {
function r(r) {
for (var t, n, e = "", i = 0; !isNaN(t = r.charCodeAt(i++)); ) n = t.toString(16),
e += 256 > t ? "\\x" + (t > 15 ? "" :"0") + n :"\\u" + ("0000" + n).slice(-4);
return e;
}
var a, c, o, u, s, e = "", i = this, t = [ "/", '"' ], n = [ "\\/", '\\"' ];
for (a = 0; a < i.length; a++) c = i.charCodeAt(a), o = i.charAt(a), u = t.indexOf(o),
u > -1 ? e += n[u] :c > 126 && 65536 > c ? (s = r(o), e += s) :e += o;
return e;
@JavaScript-Packer
JavaScript-Packer / escape-any-UTF-character.js
Created August 21, 2015 10:55
Unicode and hexdecimal encoding so that less characters used when character code range is less than 256
function unicodeEscape(d) {
for (var b = "", e = 0, a, c; !isNaN(a = d.charCodeAt(e++)); ) c = a.toString(16),
b += 256 > a ? "\\x" + (15 < a ? "" :"0") + c :"\\u" + ("0000" + c).slice(-4);
return b;
}
alert(unicodeEscape("test"));