User:Alexis Jazz/AJSJSMangler.js

//AJSJSMangler is a script that can mangle your userscripts to make them smaller. It doesn't replace UglifyJS, it's meant to be used in addition to a minifier. // AJSJSMangler is public domain, irrevocably released as WTFPL Version 2 by its author, Alexis Jazz. If you don't like that or think it's invalid where you live you may use this under CC BY-SA 3.0, CC BY 2.5 or CC BY 4.0 instead. Your choice. //Usage: run mw.loader.load('//en.wikipedia.org/w/index.php?title=User:Alexis_Jazz/AJSJSMangler.js&action=raw&ctype=text/javascript'); from the JS console. If you can't do that, this script is not for you. //Paste your script, mangle it, then process it with a regular minifier like minJS or UglifyJS (online demo: https://lisperator.net/uglifyjs/#demo) //Rules: //The first occurence of "window.myScriptsMainVariableName = {};" will be assumed to be the main variable of your script. //This variable and its contents CANNOT be shared with other script files. //Put ALL your crap in there! //Only myScriptsMainVariableName.someNameToBeMangled gets mangled. In myScriptsMainVariableName.someNameToBeMangled.someObject, "someObject" is SAFE from mangling. //Any line that contains myScriptsMainVariableName.debug gets removed entirely. //ZERO CHECKS IF THIS BREAKS YOUR SCRIPT. IF YOU FOLLOWED THE RULES IT SHOULDN'T. PROBABLY. YMMV. PROVIDED AS IS. GARBAGE IN, GARBAGE OUT. //For example, myScript.text1 = 'Content text' becomes myScript.AA = 'Content text'; window.AJSJSM = {}; var mw = window.mw; var AJSJSM = window.AJSJSM; $('body').append(' A J\' s J S M a n g l e r If you think this comes with any warranty you\'re an idiot. BEGONE    Remove comments  Remove some whitespace   Remove some newlines   Remove some more whitespace   Abbreviate some camelCase functions (very risky, variable names must be unique (or the same position perhaps also works), can\'t recycle the same name for different functions)   ALL OF THE ABOVE, YOLO!  MANGLE  Log to console '); $('#AJSJSMall').on('change',function{ $('#removecomments')[0].checked = $('#AJSJSMall')[0].checked; $('#AJSJSMclearwhitespace')[0].checked = $('#AJSJSMall')[0].checked; $('#AJSJSMclearnewlines')[0].checked = $('#AJSJSMall')[0].checked; $('#AJSJSMtrimplusisetc')[0].checked = $('#AJSJSMall')[0].checked; $('#AJSJSMabbrfunc')[0].checked = $('#AJSJSMall')[0].checked; }); mw.util.addCSS('.AJSJSMletter{float:left;transition:all .5s ease-in;}.crooked{transform:rotate(1.5deg)}#unmangledSource,#mangledSource{width:49%;display:unset;margin:0.5%'); $('.AJSJSMletter').on('click',function {AJSJSM.warpTitle;}); AJSJSM.debug = function(text){ if ( $('#AJSJSMlog')[0].checked ) { console.log(text); } }; AJSJSM.escapeReplacement = function(text) { return text.replace(/\$/g, '$$$$'); }; AJSJSM.warpTitle = function(degrees) { for (AJSJSM.warpTitleInt=0;AJSJSM.warpTitleInt<$('.AJSJSMletter').length;AJSJSM.warpTitleInt++) { if ( typeof degrees == 'undefined' ) { AJSJSM.rotdegrees = (Math.floor(Math.random * 60) -30).toString; } else { AJSJSM.rotdegrees = degrees; }		$('.AJSJSMletter')[AJSJSM.warpTitleInt].style = 'transform:rotate(' + AJSJSM.rotdegrees + 'deg)'; } }; $('#mangle').on('click',function { $('#mangle').addClass('crooked');jQuery(document).ready(function {AJSJSM.mangle;}); }); var DelayedWarp = setInterval(function {	clearInterval(DelayedWarp);	AJSJSM.warpTitle; },50); AJSJSM.letters = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']; AJSJSM.lettersNumbers = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','0','1','2','3','4','5','6','7','8','9']; AJSJSM.mangledNamesInt = 0; AJSJSM.getMangledName = function { if ( AJSJSM.mangledNamesInt < 1612 ) { AJSJSM.mangledNamesIntFirst = AJSJSM.mangledNamesInt / 62; AJSJSM.mangledNamesIntFirst = Math.floor(AJSJSM.mangledNamesIntFirst); AJSJSM.mangledNamesIntSecond = AJSJSM.mangledNamesIntFirst * 62; AJSJSM.mangledNamesIntSecond = AJSJSM.mangledNamesInt - AJSJSM.mangledNamesIntSecond; AJSJSM.newName = AJSJSM.letters[AJSJSM.mangledNamesIntFirst] + AJSJSM.lettersNumbers[AJSJSM.mangledNamesIntSecond]; } else if ( AJSJSM.mangledNamesInt < 99944 ) { AJSJSM.mangledNamesIntFirst = AJSJSM.mangledNamesInt / 62 / 62; AJSJSM.mangledNamesIntFirst = Math.floor(AJSJSM.mangledNamesIntFirst); AJSJSM.mangledNamesIntSecond = AJSJSM.mangledNamesIntFirst * 62 * 62; AJSJSM.mangledNamesIntSecond = Math.floor((AJSJSM.mangledNamesInt - AJSJSM.mangledNamesIntSecond) / 62); AJSJSM.mangledNamesIntThird = AJSJSM.mangledNamesIntFirst * 62 * 62; AJSJSM.mangledNamesIntThird = AJSJSM.mangledNamesIntThird + (AJSJSM.mangledNamesIntSecond * 62); AJSJSM.mangledNamesIntThird = Math.floor(AJSJSM.mangledNamesInt - AJSJSM.mangledNamesIntThird); AJSJSM.newName = AJSJSM.letters[AJSJSM.mangledNamesIntFirst] + AJSJSM.lettersNumbers[AJSJSM.mangledNamesIntSecond] + AJSJSM.lettersNumbers[AJSJSM.mangledNamesIntThird]; } else { window.alert('fuck no'); }	AJSJSM.mangledNamesInt++; return AJSJSM.newName; }; AJSJSM.mangle = function { if ( $('#unmangledSource')[0].value == '' ) { $('#unmangledSource')[0].value = 'window.myScript = {};\nvar myScript = window.myScript;\nmyScript.testString1 = \'str1\';\nmyScript.testString2 = \'str2\';\nmyScript.doThing = function(firstNote,secondNote) {\n	$(\'#firstHeading\').prepend(myScript.testString1);\n	window.alert(myScript.testString2);\n	console.log(firstNote);\n	console.log(secondNote);\n};\nmyScript.doThing(\'Note 1\'.replace(/Note 1/g,\'Note 1 (replaced)\'),\'Note 2\');'; }	AJSJSM.toMangle = $('#unmangledSource')[0].value; AJSJSM.mainVar = AJSJSM.toMangle.match(/(^|\n)([ \t]*)window\.([^\s=]*)[\s]*=[\s]*\{\}/); if ( AJSJSM.mainVar && AJSJSM.mainVar[3] ) { AJSJSM.mainVar = AJSJSM.mainVar[3]; } else { AJSJSM.debug('no mainVar'); return; }	//AJSJSM.namesArrRegExp = new RegExp('[\n\t\=\(\[\; ]' + AJSJSM.mainVar + '\\.(?![Jj][Ss])([A-Za-z0-9_]+)','g');//([\.\;\t \=\]\)]) AJSJSM.namesArrRegExp = new RegExp('([ \n\t])' + AJSJSM.mainVar + '\\.([A-Za-z0-9_]*)(?![A-Za-z0-9_])(\.|[\t\n ]?\(|[\t\n ]?\)|[\t\n ]?=|[\t\n ]?\\+|,|\[|[\t\n ]*\]|;|[\t\n ]?[<>]|[\t\n ]*\}|[\t\n ]?\!| \-|[\t\n ]?&&|[\t\n ]?\|\||[\t\n ]?\\*|[\t\n ]?\/)','g');	AJSJSM.namesDoneArr = []; AJSJSM.namesArr = AJSJSM.toMangle.match(AJSJSM.namesArrRegExp); if ( ! AJSJSM.namesArr ) { AJSJSM.debug('nothing to do here?'); return; }	if ( AJSJSM.toMangle.match(/start[ ]unmangled source/) ){ AJSJSM.toMangle = AJSJSM.toMangle.replace(/[^]*start[ ]unmangled source.*[\n]?/,).replace(/[\n]?.*end[ ]unmangled source[^]*/,); }	AJSJSM.debug('remove debug lines'); AJSJSM.toMangle = AJSJSM.toMangle.replace(new RegExp('.*' + AJSJSM.mainVar + '\.debug.*','g'),'').replace(/\n\n/g,'\n').replace(/\n\n/g,'\n'); AJSJSM.debug('store single-line comments'); AJSJSM.singleLineCmt = AJSJSM.toMangle.match(/(^|[;\n\t\{\}\,])[\t ]*\/\/.*/g); //AJSJSM.toMangle = AJSJSM.toMangle.replace(/(^|[;\n\t\{\}\,])[\t ]*\/\/.*/g,'(AJSJSM'+'SINGLELINECOMMENT)'); AJSJSM.toMangle = AJSJSM.toMangle.replace(/(^|[;\n\t\{\}\,])[\t ]*\/\/.*/g,'$1'); AJSJSM.debug('store multiline comments'); AJSJSM.multiLineCmt = AJSJSM.toMangle.match(/(^|\n|\t| )\/[\\*]([^g]|g(?!lobals))(([^\\*]|[\\*][^\/])*)\*\//g); //AJSJSM.toMangle = AJSJSM.toMangle.replace(/(^|\n)\/[\\*](([^\\*]|[\\*][^\/])*)\\*\//g,'(AJSJSM'+'MULTILINECOMMENT)'); AJSJSM.toMangle = AJSJSM.toMangle.replace(/(^|\n|\t| )\/[\\*]([^g]|g(?!lobals))(([^\\*]|[\\*][^\/])*)\*\//g,'$1'); AJSJSM.debug('store single-quote strings'); AJSJSM.singleQuoteStrings = AJSJSM.toMangle.match(/[^\\]\'(([^\n\'\\]|\\.)*)(?!\\)\'/g); AJSJSM.toMangle = AJSJSM.toMangle.replace(/([^\\])\'(([^\n\'\\]|\\.)*)(?!\\)\'/g,'$1\'AJSJSM'+'SINGLEQUOTESTRING\''); AJSJSM.debug('store double-quote strings'); AJSJSM.doubleQuoteStrings = AJSJSM.toMangle.match(/[^\\]"(([^\n"\\]|\\.)*)(?!\\)"/g);	AJSJSM.toMangle = AJSJSM.toMangle.replace(/([^\\])"(([^\n"\\]|\\.)*)(?!\\)"/g,'$1"AJSJSM'+'DOUBLEQUOTESTRING"'); AJSJSM.debug('store regular expressions'); AJSJSM.regExps = AJSJSM.toMangle.match(/(\.replace\(|\.match\\/(([^\\\/\n]|\\.)*)\//g); AJSJSM.toMangle = AJSJSM.toMangle.replace(/(\.replace\(|\.match\\/(([^\\\/\n]|\\.)*)\//g,'$1/AJSJSM'+'REGEXP/'); AJSJSM.debug('mangle object keys'); for (AJSJSM.namesArrInt=0;AJSJSM.namesArrInt<AJSJSM.namesArr.length;AJSJSM.namesArrInt++){ //AJSJSM.oldVarName = AJSJSM.namesArr[AJSJSM.namesArrInt].replace(new RegExp('[^]*' + AJSJSM.mainVar + '\.([A-Za-z0-9_]+)[^]*'),'$1'); AJSJSM.oldVarName = AJSJSM.namesArr[AJSJSM.namesArrInt].match(new RegExp('[^]*' + AJSJSM.mainVar + '\.([A-Za-z0-9_]+)[^]*')); if ( AJSJSM.oldVarName && AJSJSM.oldVarName[1] ) { AJSJSM.oldVarName = AJSJSM.oldVarName[1]; }		if ( AJSJSM.namesDoneArr.indexOf(AJSJSM.oldVarName) == -1 && AJSJSM.oldVarName ) { AJSJSM.debug('compact ' + AJSJSM.oldVarName); AJSJSM.namesDoneArr.push(AJSJSM.oldVarName); AJSJSM.newVarName = AJSJSM.getMangledName; AJSJSM.toMangle = AJSJSM.toMangle.replace(new RegExp('([^\.A-Za-z0-9_])' + AJSJSM.mainVar + '\.' + AJSJSM.oldVarName + '([^A-Za-z0-9_])','g'),'$1' + AJSJSM.mainVar + '.' + AJSJSM.newVarName + '$2'); AJSJSM.debug('mangled object key ' + AJSJSM.oldVarName + ' into ' + AJSJSM.newVarName); }	}	if ( $('#AJSJSMclearwhitespace')[0].checked ) { AJSJSM.toMangle = AJSJSM.toMangle.replace(/\n[ \t]*/g,'\n').replace(/[\t ]*(if|else|else if|while|for)[\t ]*(\(|\{)[\t ]*/g,'$1$2').replace(/[ ]?\)[ ]?\{\n/g,'){\n').replace(/[ ]?(\))?[ ]?(&&|==|!=|\|\|)[ ]?(\?[ ]?/g,'$1$2$3').replace(new RegExp(mw.util.escapeRegExp(AJSJSM.mainVar) + '(\.[A-Za-z0-9]*)[ ]?=[ ]?','g'),AJSJSM.mainVar + '$1=').replace(/',[\t]*'/g,'\',\'').replace(/ + /g,'+').replace(/\] \)/,'])');	}	if ( $('#AJSJSMtrimplusisetc')[0].checked ) {		AJSJSM.toMangle = AJSJSM.toMangle.replace(/([^A-Za-z]) ([^A-Za-z])/g,'$1$2');		AJSJSM.toMangle = AJSJSM.toMangle.replace(/[ \n\t]*\},[ ]?\{[ \n\t]*/g,'},{');		AJSJSM.toMangle = AJSJSM.toMangle.replace(/[ \n\t]*([\+=])[ \n\t]*/g,'$1');		AJSJSM.toMangle = AJSJSM.toMangle.replace(/[ \n\t]*\}[ \n\t]*\,[ \n\t]*\{[ \n\t]*/g,'},{');		AJSJSM.toMangle = AJSJSM.toMangle.replace(/\'\, /g,'\',');		AJSJSM.toMangle = AJSJSM.toMangle.replace(/\)\{ /g,'){'); AJSJSM.toMangle = AJSJSM.toMangle.replace(/,([a-z]*): /g,',$1:'); AJSJSM.toMangle = AJSJSM.toMangle.replace(/,[ \n\t]*([a-z]*):[ \n\t]*/g,',$1:'); AJSJSM.toMangle = AJSJSM.toMangle.replace(/\{[ \n\t]*([a-z]*):[ \n\t]*/g,'{$1:'); AJSJSM.toMangle = AJSJSM.toMangle.replace(/, /g,','); AJSJSM.toMangle = AJSJSM.toMangle.replace(/[ ]?function[ ]?/g,'function'); AJSJSM.toMangle = AJSJSM.toMangle.replace(/\[ '/g,'[\''); AJSJSM.toMangle = AJSJSM.toMangle.replace(/[ ]?<[ ]?/g,'<'); AJSJSM.toMangle = AJSJSM.toMangle.replace(/[ ]?>[ ]?/g,'>'); AJSJSM.toMangle = AJSJSM.toMangle.replace(/function\([ ]?([^ \)]*)[ ]?\)/g,'function($1)');		AJSJSM.toMangle = AJSJSM.toMangle.replace(/\[[ ]?([A-Za-z0-9\.]*)[ ]?\]/g,'[$1]');		AJSJSM.toMangle = AJSJSM.toMangle.replace(/: \[/g,':[');		/*		AJSJSM.toMangle = AJSJSM.toMangle.replace(/[ ]?([\+=])[ ]?/g,'$1')		.replace(/[ ]?\},[ ]?\{[ ]?/g,'},{')		.replace(/\} \)/g,'})')		.replace(/ { /g,'{').replace(/ } /g,'}')		.replace(/\{[ ]?([A-Za-z0-9]+):[ ]?/g,'{$1:')		.replace(/\[ '/g,'[\'').replace(/' \]/g,'\']')		.replace(/', /g,'\',')		.replace(/': /g,'\':')		.replace(/\( \{/g,'({');		*/	}

if ( $('#AJSJSMabbrfunc')[0].checked ) { AJSJSM.functionDoneArr = []; //first function argument AJSJSM.functionArr = AJSJSM.toMangle.match(/function[ ]?\([ ]?([a-z][A-Za-z0-9]*[A-Z][A-Za-z0-9]*)/g);		if ( AJSJSM.functionArr ) {			for(AJSJSM.funcArrInt=0;AJSJSM.funcArrInt<AJSJSM.functionArr.length;AJSJSM.funcArrInt++){				if ( ! AJSJSM.functionDoneArr.includes(AJSJSM.functionArr[AJSJSM.funcArrInt])){					AJSJSM.funcName = AJSJSM.functionArr[AJSJSM.funcArrInt].replace(/function[ ]?\([ ]?/,''); AJSJSM.functionDoneArr.push(AJSJSM.funcName); AJSJSM.toMangle = AJSJSM.toMangle.replace(new RegExp('([^A-Z-a-z0-9])' + AJSJSM.funcName + '([^A-Z-a-z0-9])','g'),'$1a$2'); }			}		}		//second function argument AJSJSM.functionArr = AJSJSM.toMangle.match(/function[ ]?\([ ]?[A-Za-z0-9]*,[ ]?([a-z][A-Za-z0-9]*[A-Z][A-Za-z0-9]*)/g);		if ( AJSJSM.functionArr ) {			for(AJSJSM.funcArrInt=0;AJSJSM.funcArrInt<AJSJSM.functionArr.length;AJSJSM.funcArrInt++){				if ( ! AJSJSM.functionDoneArr.includes(AJSJSM.functionArr[AJSJSM.funcArrInt])){					AJSJSM.funcName = AJSJSM.functionArr[AJSJSM.funcArrInt].replace(/function[ ]?\([ ]?[A-Za-z0-9]*,[ ]?/,''); AJSJSM.functionDoneArr.push(AJSJSM.funcName); AJSJSM.toMangle = AJSJSM.toMangle.replace(new RegExp('([^A-Z-a-z0-9])' + AJSJSM.funcName + '([^A-Z-a-z0-9])','g'),'$1b$2'); }			}		}		//third function argument AJSJSM.functionArr = AJSJSM.toMangle.match(/function[ ]?\([ ]?[A-Za-z0-9]*,[ ]?[A-Za-z0-9]*,[ ]?([a-z][A-Za-z0-9]*[A-Z][A-Za-z0-9]*)/g);		if ( AJSJSM.functionArr ) {			for(AJSJSM.funcArrInt=0;AJSJSM.funcArrInt<AJSJSM.functionArr.length;AJSJSM.funcArrInt++){				if ( ! AJSJSM.functionDoneArr.includes(AJSJSM.functionArr[AJSJSM.funcArrInt])){					AJSJSM.funcName = AJSJSM.functionArr[AJSJSM.funcArrInt].replace(/function[ ]?\([ ]?[A-Za-z0-9]*,[ ]?[A-Za-z0-9]*,[ ]?/,''); AJSJSM.functionDoneArr.push(AJSJSM.funcName); AJSJSM.toMangle = AJSJSM.toMangle.replace(new RegExp('([^A-Z-a-z0-9])' + AJSJSM.funcName + '([^A-Z-a-z0-9])','g'),'$1c$2'); }			}		}		//fourth function argument AJSJSM.functionArr = AJSJSM.toMangle.match(/function[ ]?\([ ]?[A-Za-z0-9]*,[ ]?[A-Za-z0-9]*,[ ]?[A-Za-z0-9]*,[ ]?([a-z][A-Za-z0-9]*[A-Z][A-Za-z0-9]*)/g);		if ( AJSJSM.functionArr ) {			for(AJSJSM.funcArrInt=0;AJSJSM.funcArrInt<AJSJSM.functionArr.length;AJSJSM.funcArrInt++){				if ( ! AJSJSM.functionDoneArr.includes(AJSJSM.functionArr[AJSJSM.funcArrInt])){					AJSJSM.funcName = AJSJSM.functionArr[AJSJSM.funcArrInt].replace(/function[ ]?\([ ]?[A-Za-z0-9]*,[ ]?[A-Za-z0-9]*,[ ]?[A-Za-z0-9]*,[ ]?/,''); AJSJSM.functionDoneArr.push(AJSJSM.funcName); AJSJSM.toMangle = AJSJSM.toMangle.replace(new RegExp('([^A-Z-a-z0-9])' + AJSJSM.funcName + '([^A-Z-a-z0-9])','g'),'$1d$2'); }			}		}		//fifth function argument AJSJSM.functionArr = AJSJSM.toMangle.match(/function[ ]?\([ ]?[A-Za-z0-9]*,[ ]?[A-Za-z0-9]*,[ ]?[A-Za-z0-9]*,[ ]?[A-Za-z0-9]*,[ ]?([a-z][A-Za-z0-9]*[A-Z][A-Za-z0-9]*)/g);		if ( AJSJSM.functionArr ) {			for(AJSJSM.funcArrInt=0;AJSJSM.funcArrInt<AJSJSM.functionArr.length;AJSJSM.funcArrInt++){				if ( ! AJSJSM.functionDoneArr.includes(AJSJSM.functionArr[AJSJSM.funcArrInt])){					AJSJSM.funcName = AJSJSM.functionArr[AJSJSM.funcArrInt].replace(/function[ ]?\([ ]?[A-Za-z0-9]*,[ ]?[A-Za-z0-9]*,[ ]?[A-Za-z0-9]*,[ ]?[A-Za-z0-9]*,[ ]?/,''); AJSJSM.functionDoneArr.push(AJSJSM.funcName); AJSJSM.toMangle = AJSJSM.toMangle.replace(new RegExp('([^A-Z-a-z0-9])' + AJSJSM.funcName + '([^A-Z-a-z0-9])','g'),'$1e$2'); }			}		}		//sixth function argument AJSJSM.functionArr = AJSJSM.toMangle.match(/function[ ]?\([ ]?[A-Za-z0-9]*,[ ]?[A-Za-z0-9]*,[ ]?[A-Za-z0-9]*,[ ]?[A-Za-z0-9]*,[ ]?[A-Za-z0-9]*,[ ]?([a-z][A-Za-z0-9]*[A-Z][A-Za-z0-9]*)/g);		if ( AJSJSM.functionArr ) {			for(AJSJSM.funcArrInt=0;AJSJSM.funcArrInt<AJSJSM.functionArr.length;AJSJSM.funcArrInt++){				if ( ! AJSJSM.functionDoneArr.includes(AJSJSM.functionArr[AJSJSM.funcArrInt])){					AJSJSM.funcName = AJSJSM.functionArr[AJSJSM.funcArrInt].replace(/function[ ]?\([ ]?[A-Za-z0-9]*,[ ]?[A-Za-z0-9]*,[ ]?[A-Za-z0-9]*,[ ]?[A-Za-z0-9]*,[ ]?[A-Za-z0-9]*,[ ]?/,''); AJSJSM.functionDoneArr.push(AJSJSM.funcName); AJSJSM.toMangle = AJSJSM.toMangle.replace(new RegExp('([^A-Z-a-z0-9])' + AJSJSM.funcName + '([^A-Z-a-z0-9])','g'),'$1f$2'); }			}		}		//seventh function argument AJSJSM.functionArr = AJSJSM.toMangle.match(/function[ ]?\([ ]?[A-Za-z0-9]*,[ ]?[A-Za-z0-9]*,[ ]?[A-Za-z0-9]*,[ ]?[A-Za-z0-9]*,[ ]?[A-Za-z0-9]*,[ ]?[A-Za-z0-9]*,[ ]?([a-z][A-Za-z0-9]*[A-Z][A-Za-z0-9]*)/g);		if ( AJSJSM.functionArr ) {			for(AJSJSM.funcArrInt=0;AJSJSM.funcArrInt<AJSJSM.functionArr.length;AJSJSM.funcArrInt++){				if ( ! AJSJSM.functionDoneArr.includes(AJSJSM.functionArr[AJSJSM.funcArrInt])){					AJSJSM.funcName = AJSJSM.functionArr[AJSJSM.funcArrInt].replace(/function[ ]?\([ ]?[A-Za-z0-9]*,[ ]?[A-Za-z0-9]*,[ ]?[A-Za-z0-9]*,[ ]?[A-Za-z0-9]*,[ ]?[A-Za-z0-9]*,[ ]?[A-Za-z0-9]*,[ ]?/,''); AJSJSM.functionDoneArr.push(AJSJSM.funcName); AJSJSM.toMangle = AJSJSM.toMangle.replace(new RegExp('([^A-Z-a-z0-9])' + AJSJSM.funcName + '([^A-Z-a-z0-9])','g'),'$1g$2'); }			}		}		//eighth function argument. What, you have more? Sucks to be you AJSJSM.functionArr = AJSJSM.toMangle.match(/function[ ]?\([ ]?[A-Za-z0-9]*,[ ]?[A-Za-z0-9]*,[ ]?[A-Za-z0-9]*,[ ]?[A-Za-z0-9]*,[ ]?[A-Za-z0-9]*,[ ]?[A-Za-z0-9]*,[ ]?[A-Za-z0-9]*,[ ]?([a-z][A-Za-z0-9]*[A-Z][A-Za-z0-9]*)/g);		if ( AJSJSM.functionArr ) {			for(AJSJSM.funcArrInt=0;AJSJSM.funcArrInt<AJSJSM.functionArr.length;AJSJSM.funcArrInt++){				if ( ! AJSJSM.functionDoneArr.includes(AJSJSM.functionArr[AJSJSM.funcArrInt])){					AJSJSM.funcName = AJSJSM.functionArr[AJSJSM.funcArrInt].replace(/function[ ]?\([ ]?[A-Za-z0-9]*,[ ]?[A-Za-z0-9]*,[ ]?[A-Za-z0-9]*,[ ]?[A-Za-z0-9]*,[ ]?[A-Za-z0-9]*,[ ]?[A-Za-z0-9]*,[ ]?[A-Za-z0-9]*,[ ]?/,''); AJSJSM.functionDoneArr.push(AJSJSM.funcName); AJSJSM.toMangle = AJSJSM.toMangle.replace(new RegExp('([^A-Z-a-z0-9])' + AJSJSM.funcName + '([^A-Z-a-z0-9])','g'),'$1h$2'); }			}		}	}	if ( AJSJSM.regExps ){ //AJSJSM.regExps[0].replace(/^\.(replace|match)\(/,);		AJSJSM.debug('restore regular expressions');		for (AJSJSM.regExpsInt=0;AJSJSM.regExpsInt<AJSJSM.regExps.length;AJSJSM.regExpsInt++){			AJSJSM.toMangle = AJSJSM.toMangle.replace(/\/[A]JSJSMREGEXP\//,AJSJSM.escapeReplacement(AJSJSM.regExps[AJSJSM.regExpsInt].replace(/^\.(replace|match)\(/,))); }	}		if ( AJSJSM.doubleQuoteStrings ){ AJSJSM.debug('restore double quote strings'); for (AJSJSM.doubleQuoteStringsInt=0;AJSJSM.doubleQuoteStringsInt<AJSJSM.doubleQuoteStrings.length;AJSJSM.doubleQuoteStringsInt++){ AJSJSM.toMangle = AJSJSM.toMangle.replace(/"[A]JSJSMDOUBLEQUOTESTRING"/,'"' + AJSJSM.escapeReplacement(AJSJSM.doubleQuoteStrings[AJSJSM.doubleQuoteStringsInt].slice(2).slice(0,-1)) + '"'); }	}	if ( AJSJSM.singleQuoteStrings ){ AJSJSM.debug('restore single quote strings'); for (AJSJSM.singleQuoteStringsInt=0;AJSJSM.singleQuoteStringsInt<AJSJSM.singleQuoteStrings.length;AJSJSM.singleQuoteStringsInt++){ AJSJSM.toMangle = AJSJSM.toMangle.replace(/'[A]JSJSMSINGLEQUOTESTRING'/,'\ + AJSJSM.escapeReplacement(AJSJSM.singleQuoteStrings[AJSJSM.singleQuoteStringsInt].slice(2).slice(0,-1)) + '\); }	}	if ( $('#AJSJSMclearnewlines')[0].checked ) { AJSJSM.toMangle = AJSJSM.toMangle.replace(/([;\{\}\,])\n/g,'$1').replace(/[\n]{2,}/g,'\n').replace(/'[ ]?\+[ ]?\n[ ]?'/g,''); }	if ( $('#removecomments')[0].checked ) { AJSJSM.debug('removing comments'); AJSJSM.toMangle = AJSJSM.toMangle.replace(/[A]JSJSMSINGLELINECOMMENT/g,).replace(/[A]JSJSMMULTILINECOMMENT/g,); } else { if ( AJSJSM.multiLineCmt ){ AJSJSM.debug('restore multiline comments'); for (AJSJSM.multiLineCmtInt=0;AJSJSM.multiLineCmtInt<AJSJSM.multiLineCmt.length;AJSJSM.multiLineCmtInt++){ AJSJSM.toMangle = AJSJSM.toMangle.replace(/\([A]JSJSMMULTILINECOMMENT\)/,AJSJSM.escapeReplacement(AJSJSM.multiLineCmt[AJSJSM.multiLineCmtInt])); }		}		if ( AJSJSM.singleLineCmt ){ AJSJSM.debug('restore singleline comments'); for (AJSJSM.singleLineCmtInt=0;AJSJSM.singleLineCmtInt<AJSJSM.singleLineCmt.length;AJSJSM.singleLineCmtInt++){ AJSJSM.toMangle = AJSJSM.toMangle.replace(/\([A]JSJSMSINGLELINECOMMENT\)/,AJSJSM.escapeReplacement(AJSJSM.singleLineCmt[AJSJSM.singleLineCmtInt])); }		}	}	$('#mangledSource')[0].value = AJSJSM.toMangle.trim; $('#mangle').removeClass('crooked'); AJSJSM.warpTitle; }; //