Skip to content

Instantly share code, notes, and snippets.

@valyrie97
Last active August 21, 2018 20:53
Show Gist options
  • Save valyrie97/89c6e85ea0997814bd0b6a8dab656a96 to your computer and use it in GitHub Desktop.
Save valyrie97/89c6e85ea0997814bd0b6a8dab656a96 to your computer and use it in GitHub Desktop.
window.stripComments = (function stripComments() {
var _0xa0dc = ["length", "getValue", "editor", "innerHTML", "inputLength", "getElementById", "#AD2D3A", "bold", "css", "#inputLength", "#444444", "normal", "match", "href", "location", "run_tests", "<br>", "replace", "�", "&nbsp;", "&gt;", "&lt;", "&amp;", "results_raw", "show", "html", "#testresults", "tabsize", "cookie", "4", "val", "#tabsize", "brace-style", "collapse", "#brace-style", "checked", "detect-packers", "off", "prop", "#detect-packers", "max-preserve-newlines", "5", "#max-preserve-newlines", "keep-array-indentation", "on", "#keep-array-indentation", "break-chained-methods", "#break-chained-methods", "indent-scripts", "#indent-scripts", "space-before-conditional", "#space-before-conditional", "wrap-line-length", "0", "#wrap-line-length", "unescape-strings", "#unescape-strings", "jslint-happy", "#jslint-happy", "end-with-newline", "#end-with-newline", "indent-inner-html", "#indent-inner-html", "comma-first", "#comma-first", "e4x", "#e4x", "", "test", "*/", "indexOf", "substr", "\n", "detect", "unpack", "beautify_in_progress", "#source", "indent_size", "indent_char", "\t", " ", "max_preserve_newlines", "preserve_newlines", "-1", "keep_array_indentation", "break_chained_methods", "indent_scripts", "brace_style", "space_before_conditional", "unescape_strings", "jslint_happy", "end_with_newline", "wrap_line_length", "indent_inner_html", "comma_first", "setValue", "ml-cl", "domain", "<", "!-", "-", "substring", "use_codemirror", "undefined", "default", "fromTextArea", "change", "focus", "click", ".CodeMirror", "blur", "bind", "click focus", "keydown", "ctrlKey", "keyCode", ".submit", "select", "//This is just a demo script.\n\nif (abc==xyz){of_beautifier();}else{var a=b?(c%d):e[f];}", "/", "*", "setIndex", "useNew", "USE_NEW", "SET_INDEX", "DEFAULT_INDEX", "indexProp", "rules", "errorLexeme", "NULL_LEXEME", "ERROR_LEXEME", "[object Lexer.ERROR_LEXEME]", "index", "callee", "apply", "a[", "]", "push", "var a=arguments;return new this(", "join", ");", "global", "g", "ignoreCase", "i", "multiline", "m", "sticky", "y", "source", "regex", "lexeme", "prototype", "function", "input", "concat", "lastIndex", "exec", "filter", "runLexeme", "call", "last", "getFlags", "slice", "INTERSECT_FLAGS", "pop", "string", "hasOwnProperty", "charAt", "UNION_FLAGS", "group", "(?:", ")", "optional", "?", "or", "|", "many", "many1", "+", "addRule", "lex", "#removeCommentButton", ".clearButton", ".undoButton", "font-size", "px", ".CodeMirror-code", "line-height", ".sourceSmallerFont", ".sourceBiggerFont", ".textBiggerSmaller span", "ready"], undotext, text, sourceFontSize = 12, the = {
use_codemirror: !window[_0xa0dc[14]][_0xa0dc[13]][_0xa0dc[12]](/without-codemirror/),
beautify_in_progress: !1,
editor: null
};
function stripComments(a) {
function c() {
this[_0xa0dc[121]] = !1,
this[_0xa0dc[122]] = !1;
for (var a = 0; a < arguments[_0xa0dc[0]]; ++a) {
var d = arguments[a];
d === c[_0xa0dc[123]] ? this[_0xa0dc[122]] = !0 : d === c[_0xa0dc[124]] ? this[_0xa0dc[121]] = c[_0xa0dc[125]] : d instanceof c[_0xa0dc[124]] && (this[_0xa0dc[121]] = d[_0xa0dc[126]])
}
this[_0xa0dc[127]] = [],
this[_0xa0dc[128]] = null
}
function d(a) {
return a
}
c[_0xa0dc[129]] = {},
c[_0xa0dc[130]] = {
toString: function() {
return _0xa0dc[131]
}
},
c[_0xa0dc[125]] = _0xa0dc[132],
c[_0xa0dc[123]] = {},
c[_0xa0dc[124]] = function(a) {
if (!(this instanceof arguments[_0xa0dc[133]]))
return new arguments[_0xa0dc[133]][_0xa0dc[134]](this,arguments);
void 0 === a && (a = c[_0xa0dc[125]]),
this[_0xa0dc[126]] = a
},
function() {
function a(a) {
for (var c = _0xa0dc[67], d = 0; d < e[_0xa0dc[0]]; ++d)
a[e[d][0]] && (c += e[d][1]);
return c
}
function d(a) {
return function(c) {
return a !== c
}
}
function _(c, d) {
if (!c[_0xa0dc[141]]) {
var _ = _0xa0dc[142] + a(c);
c = new RegExp(c[_0xa0dc[149]],_)
}
this[_0xa0dc[150]] = c,
this[_0xa0dc[151]] = d
}
var x = function() {
var a = [];
return function() {
var c = a[arguments[_0xa0dc[0]]];
if (c)
return c[_0xa0dc[134]](this, arguments);
for (var d = [], _ = 0; _ < arguments[_0xa0dc[0]]; ++_)
d[_0xa0dc[137]](_0xa0dc[135] + _ + _0xa0dc[136]);
return c = new Function(_0xa0dc[138] + d[_0xa0dc[139]]() + _0xa0dc[140]),
arguments[_0xa0dc[0]] < 100 && (a[arguments[_0xa0dc[0]]] = c),
c[_0xa0dc[134]](this, arguments)
}
}()
, e = [[_0xa0dc[141], _0xa0dc[142]], [_0xa0dc[143], _0xa0dc[144]], [_0xa0dc[145], _0xa0dc[146]], [_0xa0dc[147], _0xa0dc[148]]];
c[_0xa0dc[152]] = {
constructor: c,
addRule: function(a, c) {
var d = new _(a,c);
this[_0xa0dc[127]][_0xa0dc[137]](d)
},
setErrorLexeme: function(a) {
this[_0xa0dc[128]] = a
},
runLexeme: function(a, c) {
if (typeof a !== _0xa0dc[153])
return a;
var d = c[_0xa0dc[155]](c[_0xa0dc[132]], c[_0xa0dc[154]]);
return this[_0xa0dc[122]] ? x[_0xa0dc[134]](a, d) : a[_0xa0dc[134]](null, d)
},
lex: function(a) {
var _ = 0
, x = [];
for (this[_0xa0dc[121]] && (x[_0xa0dc[137]] = function() {
for (var a = 0; a < arguments[_0xa0dc[0]]; ++a)
arguments[a] && (arguments[a][this[_0xa0dc[121]]] = _);
return Array[_0xa0dc[152]][_0xa0dc[137]][_0xa0dc[134]](this, arguments)
}
); _ < a[_0xa0dc[0]]; ) {
for (var e = null, t = null, n = 0; n < this[_0xa0dc[127]][_0xa0dc[0]]; ++n) {
var r = this[_0xa0dc[127]][n];
r[_0xa0dc[150]][_0xa0dc[156]] = _;
var i = r[_0xa0dc[150]][_0xa0dc[157]](a);
i && (!e || i[_0xa0dc[132]] < e[_0xa0dc[132]] || i[_0xa0dc[132]] === e[_0xa0dc[132]] && i[0][_0xa0dc[0]] > e[0][_0xa0dc[0]]) && (e = i,
t = r)
}
if (e) {
this[_0xa0dc[128]] && _ !== e[_0xa0dc[132]] && x[_0xa0dc[137]](this[_0xa0dc[128]]);
var o = this[_0xa0dc[159]](t[_0xa0dc[151]], e);
x[_0xa0dc[137]](o),
_ = t[_0xa0dc[150]][_0xa0dc[156]]
} else {
if (this[_0xa0dc[128]])
return x[_0xa0dc[137]](this[_0xa0dc[128]]),
x[_0xa0dc[158]](d(c.NULL_LEXEME));
++_
}
}
return x[_0xa0dc[158]](d(c.NULL_LEXEME))
}
}
}(),
Array[_0xa0dc[152]][_0xa0dc[158]] || (Array[_0xa0dc[152]][_0xa0dc[158]] = function(a) {
for (var c = this[_0xa0dc[0]] >>> 0, d = [], _ = arguments[1], x = 0; x < c; ++x)
if (x in this) {
var e = this[x];
a[_0xa0dc[160]](_, e, x, this) && d[_0xa0dc[137]](e)
}
return d
}
),
Array[_0xa0dc[152]][_0xa0dc[161]] = function() {
return this[this[_0xa0dc[0]] - 1]
}
,
RegExp[_0xa0dc[152]][_0xa0dc[162]] = function() {
var a = [[_0xa0dc[141], _0xa0dc[142]], [_0xa0dc[143], _0xa0dc[144]], [_0xa0dc[145], _0xa0dc[146]], [_0xa0dc[147], _0xa0dc[148]]];
return function() {
for (var c = _0xa0dc[67], d = 0; d < a[_0xa0dc[0]]; ++d)
this[a[d][0]] && (c += a[d][1]);
return c
}
}(),
RegExp[_0xa0dc[155]] = function() {
var a = Array[_0xa0dc[152]][_0xa0dc[163]][_0xa0dc[160]](arguments)
, c = _0xa0dc[67]
, d = a[0][_0xa0dc[162]] && a[0][_0xa0dc[162]]() || _0xa0dc[67]
, _ = RegExp[_0xa0dc[155]][_0xa0dc[164]];
typeof a[_0xa0dc[161]]() === _0xa0dc[153] && (_ = a[_0xa0dc[165]]());
for (var x = 0; x < a[_0xa0dc[0]]; ++x) {
var e = a[x];
typeof e === _0xa0dc[166] ? (d = _(d, _0xa0dc[67]),
c += e) : (d = _(d, e[_0xa0dc[162]]()),
c += e[_0xa0dc[149]])
}
return new RegExp(c,d)
}
,
function() {
function a(a) {
var c = _0xa0dc[67];
for (var d in a)
a[_0xa0dc[167]](d) && a[d] && (c += d);
return c
}
function c(a) {
for (var c = {}, d = 0; d < a[_0xa0dc[0]]; ++d)
c[a[_0xa0dc[168]](d)] = !0;
return c
}
function d(a, c) {
for (var d in c)
c[_0xa0dc[167]](d) && (a[d] = !0);
return a
}
function _(a, c) {
for (var d in c)
c[_0xa0dc[167]](d) && !c[d] && delete a[d];
return a
}
RegExp[_0xa0dc[155]][_0xa0dc[169]] = function(_, x) {
return a(d(c(_), c(x)))
}
,
RegExp[_0xa0dc[155]][_0xa0dc[164]] = function(d, x) {
return a(_(c(d), c(x)))
}
}(),
RegExp[_0xa0dc[152]][_0xa0dc[170]] = function() {
return RegExp[_0xa0dc[155]](_0xa0dc[171], this, _0xa0dc[172], RegExp[_0xa0dc[155]].UNION_FLAGS)
}
,
RegExp[_0xa0dc[152]][_0xa0dc[173]] = function() {
return RegExp[_0xa0dc[155]](this[_0xa0dc[170]](), _0xa0dc[174], RegExp[_0xa0dc[155]].UNION_FLAGS)
}
,
RegExp[_0xa0dc[152]][_0xa0dc[175]] = function(a) {
return RegExp[_0xa0dc[155]](this, _0xa0dc[176], a, RegExp[_0xa0dc[155]].UNION_FLAGS)[_0xa0dc[170]]()
}
,
RegExp[_0xa0dc[152]][_0xa0dc[177]] = function() {
return RegExp[_0xa0dc[155]](this[_0xa0dc[170]](), _0xa0dc[120], RegExp[_0xa0dc[155]].UNION_FLAGS)
}
,
RegExp[_0xa0dc[152]][_0xa0dc[178]] = function() {
return RegExp[_0xa0dc[155]](this[_0xa0dc[170]](), _0xa0dc[179], RegExp[_0xa0dc[155]].UNION_FLAGS)
}
;
var _ = /(?![\S\s])/m
, x = /\r?\n/m
, e = /[\t ]*/m
, t = RegExp[_0xa0dc[155]](/^/m, e)
, n = RegExp[_0xa0dc[155]](e, /$/m)
, r = /\/\*(?!@)(?:[^*]|\*[^/])*\*\//m
, i = /\/\/(?!@).*/m[_0xa0dc[175]](r)
, o = RegExp[_0xa0dc[155]](i, RegExp[_0xa0dc[155]](e, i)[_0xa0dc[177]]())
, s = RegExp[_0xa0dc[155]](t, o, n, _)
, u = RegExp[_0xa0dc[155]](t, o, n, x)
, f = /\/\/@.*/
, h = /\/\*@(?:[^*]|\*[^@]|\*@[^/])*@*\*\//
, l = /"(?:[^\\"]|\\.)*"/
, $ = /'(?:[^\\']|\\.)*'/
, p = /\/(?![/*])(?:[^/\\[]|\\.|\[(?:[^\]\\]|\\.)*\])*\//
, m = /[\S\s]/
, g = new c;
return g[_0xa0dc[180]](u, c.NULL_LEXEME),
g[_0xa0dc[180]](RegExp[_0xa0dc[155]](x, u[_0xa0dc[177]](), s), c.NULL_LEXEME),
g[_0xa0dc[180]](RegExp[_0xa0dc[155]](i, RegExp[_0xa0dc[155]](n, x, s)[_0xa0dc[173]]()), c.NULL_LEXEME),
g[_0xa0dc[180]](f, d),
g[_0xa0dc[180]](h, d),
g[_0xa0dc[180]](l, d),
g[_0xa0dc[180]]($, d),
g[_0xa0dc[180]](p, d),
g[_0xa0dc[180]](m, d),
g[_0xa0dc[181]](a)[_0xa0dc[139]](_0xa0dc[67])
}
return stripComments;
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment