URL Variable Obfuscator Source

JavaScript

var level = 1;
 
$(document).ready(function(){
	OnChange();
});
 
 
function OnChange() {
	field = document.Obfuscator.Input;
	level = Slider.instanz['level'].wert;
	var split = field.value.split("\n");
	var array = new Array()
	for (var i = 0; i < split.length; i++) {
		array[i] = URLVarHide(split[i], level);;
	}
	document.Obfuscator.Output.value = array.join("\n");
}
 
function URLDecode (encodedString) {
	var output = encodedString;
	var binVal, thisString;
	var regexp = /(%[^%]{2})/;
		while ((match = regexp.exec(output)) != null && match.length > 1 && match[1] != '') { 
		binVal = parseInt(match[1].substr(1),16);
		thisString = String.fromCharCode(binVal);
		output = output.replace(match[1], thisString);
	}
	return output;
}
 
function URLVarHide (clearString, level) {
	var output = '';
	var run = false;
	if (level == 1) {
		document.getElementById('Label').innerHTML = "&bull; Hide only the value of the variable.";
		clearString = URLDecode(clearString.toString());
		var x = 0;
		var working = false;
		while (x < clearString.length) {
			if (clearString[x] == '?') {
				// Start working after char '?'
				output += clearString[x];
				working = true;
				run = false;
			} else if (clearString[x] == '=') {
				run = true;
				output += clearString[x];
			} else if (clearString[x] == '&') {
				run = false;
				output += clearString[x];
			} else if (working == true && run == true && clearString[x] != '=' && clearString[x] != '&') {
				var charCode = clearString.charCodeAt(x);
				var hexVal = charCode.toString(16);
				output += '%' + ( hexVal.length < 2 ? '0' : '' ) + hexVal.toUpperCase();
			} else {
				output += clearString[x];
			}
			x++;
		}
	} else if (level == 2) {
		document.getElementById('Label').innerHTML = "&bull; Hide the name and value of the variable.";
		clearString = URLDecode(clearString.toString());
		var x = 0;
		var working = false;
		while (x < clearString.length) {
			if (clearString[x] == '?') {
				// Start working after char '?'
				output += clearString[x];
				working = true;
 
			} else if (working == true && clearString[x] != '=' && clearString[x] != '&') {
				var charCode = clearString.charCodeAt(x);
				var hexVal = charCode.toString(16);
				output += '%' + ( hexVal.length < 2 ? '0' : '' ) + hexVal.toUpperCase();
			} else {
				output += clearString[x];
			}
			x++;
		}
	} else if (level == 3) {
		document.getElementById('Label').innerHTML = "&bull; URLDecode the URL(s) as usual.";
		clearString = URLDecode(clearString.toString());
		output = clearString.toString();
	} else if (level == 4) {
		document.getElementById('Label').innerHTML = "&bull; Same as above.";
		output = clearString.toString();
	} else {
		document.getElementById('Label').innerHTML = "&bull; Same as above.";
		output = clearString.toString();
	}
	return output;
}