OGame: Smilies

OGame: Smilies in messages

// ==UserScript==
// @name OGame: Smilies
// @namespace https://greasyfork.org/users/4668-black-cat
// @description OGame: Smilies in messages
// @version 5.4
// @creator Black Cat
// @include http://*.ogame.gameforge.com/game/index.php?*
// @run-at document-end
// ==/UserScript==

function addSmiley(t,smiley) {
	var message, cnt;
	var div = $(t).parents(".ui-dialog").find(".overlayDiv")[0];
	if (div) {
		message = div.getElementsByTagName("form")[0].text;
		cnt = div.getElementsByClassName("cntChars")[0];
	} else {
		message = document.forms[0].text;
		cnt = document.getElementsByClassName("cntChars")[0];
	}
	var selStart = message.selectionStart, selEnd = message.selectionEnd;
	var str = " " + smiley;
	var startText = message.value.substring(0,selStart);
	if (/\[[a-z][a-z ]*=[^\]]*$/i.test(startText.replace(/\\[\\\]]/g,""))) {
		str = str.replace(/([ \\\]])/g,"\\$1");
	}
	message.value = startText + str + message.value.substring(selEnd);
	selStart += str.length;
	message.setSelectionRange(selStart,selStart);
	message.focus();
	cnt.textContent = message.textLength;
}

var strFunc = (function(){
	var smilies = new Array();
	smilies.push(new Array(":D","data:image/gif;base64,R0lGODlhDwAPALMAAAAAAP///4uYp52otJ6ptaOtuaSuuqSuuqmyvay1wK+4wrC5w7K7xLe/yLnByv///yH5BAEAAA8ALAAAAAAPAA8AQARa8EkJap0UgRA294AAPEBTmgyAGMAwUoNrhSIGOI3DLMpKvIDFbFipAVgdTjL0ss0wzl3vcJncTDdGolJwkRi4Rk676ooACpASdKZ+1h8joVBZ05okmmBffUQAADs="));
	smilies.push(new Array(":O","data:image/gif;base64,R0lGODlhDwAPAMQAAAAAAP///4uYp5Whrpums52otJ6ptaOtuaSuuqSuuqmyvay1wK+4wrC5w7K7xLe/yLnByrzEzP///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAABIALAAAAAAPAA8AQAVtoCSKQFmOpMIsi1kexSAAEvDYtwMoCFDQpIKQMJAJZigA5AFxNBg8AxDQcCybzygBC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AYDgAOAAAOAAAYAAAoAAA0P/78KCgpICAgP8AAAD/AP//AAAA//8A/wD//////yH5BAEAAPoALAAAAAAPABYABwifAPXpmyBQIMGCBwcqVHiQYMKFBgtCfEhRosWLEisixMgRI4CPHzl+lCAhwgMHISUCqEChAkmTDhoAKLiyZUsJEE7GnKkPQMuPFHB+3NlTAsuPLiEMbaBgpNGbJU82YNAUQASSWGHGXFD1QQQIYLVurerggVmzDtIu4Nq0Z1qUIAGw5QmgAcqYDRosAKCgrcC6eRms7euXJl/CVUXGtRgQADs="));
	smilies.push(new Array("8-)","data:image/gif;base64,R0lGODlhDwAPAMQAAAAAAP///4uYp5Whrpums52otJ6ptaOtuaSuuqSuuqmyvay1wK+4wrC5w7K7xLe/yLnByrzEzP///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAABIALAAAAAAPAA8AQAVqoCSKQFmOpMIsLKMkyFEMAiABT1Q+zlLKNlJhSBjQBDUUAPKAOBouhCEIaDhM2BIhCUAgAInwYQBABpVYFPrpSpxGy1yzp4gVbNnSNQ9gWEtQCiUGNCUJCoiIMGNHeAYHB1lISXBlkzVnIQA7"));
	smilies.push(new Array(";(","data:image/gif;base64,R0lGODlhDwAPAMQAAAAAAP///4uYp5Whrpums52otJ6ptaOtuaSuuqSuuqmyvay1wK+4wrC5w7K7xLe/yLnByrzEzP///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAABIALAAAAAAPAA8AQAVtoCSKQFmOpMIsrIkcwSAAEvBE5eMs5VHQpILQJCgCSZAHxNFgKBAGIKDhSC6bTwNhVkMgEqaSjIuqhcujEtMJPtaSEeXu6aMBqjb54gkozAAMVA5rCgkwMiUJCothAANjdgYHB41FZCQAlkZHIQA7"));
	smilies.push(new Array("8o","data:image/gif;base64,R0lGODlhDwAPAMQAAAAAAP///4uYp5Whrpums52otJ6ptaOtuaSuuqSuuqmyvay1wK+4wrC5w7K7xLe/yLnByrzEzP///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAABIALAAAAAAPAA8AQAVzoCSKQFmOpMIsLKMkyFEMAiABT6A/zqIHBRupQDQJjkIS5AFxNFwIgxDQcPycjB+hdkMgEgnTgMZF3UxJcwn7Oo0Aywizp4gFbw5IABBo+vgFNQAMVQ5sCQcGNCUJCo4KJgdjSDcGB5cAQWRlJABHn24SIQA7"));
	smilies.push(new Array(":]","data:image/gif;base64,R0lGODlhDwAPAMQAAAAAAP///4uYp5Whrpums52otJ6ptaOtuaSuuqSuuqmyvay1wK+4wrC5w7K7xLe/yLnByrzEzP///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAABIALAAAAAAPAA8AQAVzoCSKQFmOpMIAy8IoCXIAgwBIwGM+zmIWN1JhSBjUBDYUAPKAOBovhCEIaDiYTqhCSkgCEIiEOHEwIoNKExqFAzxfidNo+Yg0e9sDEHd9+J0LeQU2AAwNbm8wMzUlCQoKaiZHNwAGB5cGQ0dJcwBIn3ISIQA7"));
	smilies.push(new Array(":(","data:image/gif;base64,R0lGODlhDwAPAMQAAAAAAP///4uYp5Whrpums52otJ6ptaOtuaSuuqSuuqmyvay1wK+4wrC5w7K7xLe/yLnByv///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAABEALAAAAAAPAA8AQAV0YCSKQFmOpMIsLKMkyFEMAhABD/48zqIggIKNVCgSBjRBDQWA5BwNBgBhGAIaDkgJKgUYCMspMEE+DADKIdOkRt0A3Ndp1Mw9ID0FQGaDO0t4CyUyNQAMWA5xCQcGNCUJCpFsAEhpNwYHmQZFSUt0aEppaiEAOw=="));
	smilies.push(new Array("=)","data:image/gif;base64,R0lGODlhDwAPAMQAAAAAAP///4uYp5Whrpums52otJ6ptaOtuaSuuqSuuqmyvay1wK+4wrC5w7K7xLe/yLnByrzEzP///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAABIALAAAAAAPAA8AQAVzoCSKQFmOpMIAy8IoCXIAgwBIwBM9ubMAssKNVCgSBjWBDQWAPCCOxgthGAIaDicguqISlkAEIEE+DADKIdOkRuG2Uthp1NQ1fcCDEJd98KA/QTYADFgOVy8ABwY1JQkKAAqSMWZoYAYHM2xKS3SWnHMSIQA7"));
	smilies.push(new Array("X(","data:image/gif;base64,R0lGODlhDwAPAMQAAAAAAP///4uYp5Whrpums52otJ6ptaOtuaSuuqSuuqmyvay1wK+4wrC5w7K7xLe/yLnByrzEzP///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAABIALAAAAAAPAA8AQAVxoCSKQFmOpMIsi1kexSAAEvBE5QO0AEyThSBhIBPMUACIztFgABCGH6DhUEKYDAWUcHwCEuDEgQg4omqu86iEVSROa2VkCdD6alVd0sGDzQAMVA5tYgYyJQkKCnVuCAcARTQABgeVBkFFZiRlRkZwEiEAOw=="));
	smilies.push(new Array(":)","data:image/gif;base64,R0lGODlhDwAPAMQAAAAAAP///4uYp5Whrpums52otJ6ptaOtuaSuuqSuuqmyvay1wK+4wrC5w7K7xLe/yLnByrzEzP///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAABIALAAAAAAPAA8AQAVxoCSKQFmOpMIsLKMkyFEMAiABT1Q+zlLKNlJhSBjQBDUUAPKAOBouhCEIaDiYTqhCSkgCEAhAYnwYAJBBpSmNugGersRptMw1e1vg7fooOX0AMjUADFYOcC8HBjQlCQoACpEwZWdeBgcHa5VJdJtoaSEAOw=="));
	smilies.push(new Array(":P","data:image/gif;base64,R0lGODlhDwAPAMQAAAAAAP///4uYp5Whrpums52otJ6ptaOtuaSuuqSuuqmyvay1wK+4wrC5w7K7xLe/yLnByrzEzG5/kTlCS////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAABQALAAAAAAPAA8AQAVzICWKQFmOpMIAy8IoCXIAgwBQwBOVj7OUh8KNVCiaBMghCfKAOBovhGEIaDiYTqhCSrDhEIgEQDKR0JIokkmZLj1fYjaAGWn6tsEb4PooOX8AQTYADFYObzAHBjUlCQoKayY1XgAGBzMSmQBIXiMlnElKIQA7"));
	smilies.push(new Array(";)","data:image/gif;base64,R0lGODlhDwAPAMQAAAAAAP///4uYp5Whrpums52otJ6ptaOtuaSuuqSuuqmyvay1wK+4wrC5w7K7xLe/yLnByrzEzP///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAABIALAAAAAAPAA8AQAVxoCSKQFmOpMIsLKMkyFEMAiABD/7kSynbpIKQMKAJaigA5AFxNFwIAxDQcCybT0WUgAQgEICE+DAAHIFJExp1AzhdidNI+YgwHQvt72bNlfA+BTUADFUOby8HBjQlCQoACpEwZGZdBgcHapVIc5tnaCEAOw=="));
	smilies.push(new Array(":rolleyes:","data:image/gif;base64,R0lGODlhDwAPAMQAAAAAAP///4uYp5Whrpums52otJ6ptaOtuaSuuqSuuqmyvay1wK+4wrC5w7K7xLe/yLnByv///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAABEALAAAAAAPAA8AQAVrYCSKQFmOpMIsJaMkZTEIQAQ8JuDkRU0WQMJgJqChAJAHxNFwIQw+QAOp3DmhRgACkegmDgNA0XfMocpMF4xsS5aWLMChZ9vhkID4QdyaOqwAXwAzJQkKh4cJCGBENQAGB3s5RUYjJZRjZCEAOw=="));
	smilies.push(new Array(":baby:","data:image/gif;base64,R0lGODlhDwAPAMQAAAAAAP///5ums6SuuqOtuamyvay1wKu0v4uYp5Whrp6ptZ2otK+4wrC5w7nByre/yHeHmLK7xLzEzP///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAABMALAAAAAAPAA8AAAVw4CSKQFmO6FRGAFMMJwo4jwM0wKsA4/xINYDhRVjwVL+HMjIcFHmACK3kYJaKiFJDumowSgpBtrWNRLxERWJcYBgMputiXRoUCoCDXg9YZ1UDMAcQhAcACH8qCgR5e4aIRyoLRnGQKSWImTEpKnEpIQA7"));
	smilies.push(new Array(":evil:","data:image/gif;base64,R0lGODlhDwAPAMQAAAAAAP///4uYp5Whrpums52otJ6ptaOtuaSuuqSuuqmyvay1wK+4wrC5w7K7xLe/yLnByrzEzP///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAABIALAAAAAAPAA8AQAVzoCSKQFmOpMIsLKMkyFEMAiABT/k8zqKUBRupQCQMSoIaCgB5QBwNF8IgBDQcEFPDZCAoAQhEYpw4HAFK1M0kVK+hrsRpxHxEnD1FLHjD5pg9JTI1AAxXDnAvBwY0JQkKkJAwZmhfBgeYBkRIaSSVSYQjIQA7"));
	smilies.push(new Array(":tongue:","data:image/gif;base64,R0lGODlhDwAPAMQAAAAAAP///4uYp5Whrpums52otJ6ptaOtuaSuuqSuuqmyvay1wK+4wrC5w7K7xLe/yLnByv///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAABEALAAAAAAPAA8AQAVtYCSKQFmOpAIsLKMkyFEAAhABD/48zqIggNkoWCgQBgOB0jaEPCCOhgthYAIaDidU+jMQajcEImEqJcGoWzk9BERdZCbJaXKYZDa3cwf1xQo1AAxYDm8vBwZJJQkqZWVLNwYHkyZnaCQ0SktyIQA7"));
	smilies.push(new Array(":supa:","data:image/gif;base64,R0lGODlhHgAPANQAAAAAAAAACAAEGAAEHAAILAAIMAAgyAAg0Fj/yOzs//T0//j//////wggGCAgIPj4+AQEBBQ8LPD/+AAEAAgIAAgICAwIAAwMABgYAAwsxDg4OFj/xFz/xGT/tGT/uPT09CH/C05FVFND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bAP/bVf/bqv/b////AP//Vf//qv///yH5BAEAAAMALAAAAAAnABIAQAjEAAcIFAigYMGBCBMqXIgQgBcA//5BjDjRoEWDETNSBAdOoKQ2DEOKHJkQgB+HJx96SQmA5ABJAtvAjFnyy5+LXx6OvAiAY0iHXrx88TP0z0mXA0DS9BiJ4EOeFr+0JDnz502JGSFCnagxa0+fIi8iHTuwoJ+VQQ+S3bmyoE2pQKeOVJp0IF2TOYei9fPHqFSqMKtWHeCwYlaKOhVulVvyKlaKkLtK9gpWcVuuBdOWtKixIMeOdBs6/CP0KVmDa1OrXk0yIAA7"));

	var smiliesHTML = "";
	var funcSmilies = function(form) {
		if (smiliesHTML.length == 0) {
			for (var i = 0; i < smilies.length; i++) {
				smiliesHTML += "<img src=\""+smilies[i][1]+"\" alt=\""+smilies[i][0]+"\" onclick=\"addSmiley(this,'"+smilies[i][0].replace(/'/g,"\\'")+"')\" style='cursor:pointer;' border='0' /> ";
			}
		}
		var sort_smilies = function(a,b) { return b[0].length-a[0].length; }
		smilies.sort(sort_smilies);
		if (!form) return;
		var footer = form.getElementsByClassName("markItUpFooter")[0];
		if (footer) {
			var div = document.createElement("div");
			div.innerHTML = smiliesHTML;
			div.style.marginTop = "5px";
			footer.appendChild(div);
		}
	}

	var rep_smilies = function(value,index) {
		var pos_less = value.indexOf("<");
		if (pos_less != -1) {
			var pos_more = value.indexOf(">",pos_less+1);
			var tag = value.substring(pos_less,pos_more+1);
			while (tag.match(/</g).length != tag.match(/>/g).length) {
				pos_more = value.indexOf(">",pos_more+1);
				tag = value.substring(pos_less,pos_more+1);
			}
			value = rep_smilies(value.substring(0,pos_less),index) +
				    tag +
				    rep_smilies(value.substring(pos_more+1),index);
		} else {
			for (var i = index; i < smilies.length; i++) {
				var pos = value.search(new RegExp(smilies[i][0].replace(/([[\](){}.+*?^$|-])/g,"\\$1"),"i"));
				if (pos != -1) {
					value = rep_smilies(value.substring(0,pos),i+1) +
						    "<img src=\""+smilies[i][1]+"\" alt=\""+smilies[i][0]+"\" border='0' />" +
						    rep_smilies(value.substring(pos+smilies[i][0].replace(/\\\\/g,"\\").length),i);
					break;

				}
			}
		}
		return value;
	}

	window.setInterval(function(){
		$(".note > .newMessage").each(function(){
			if ($(this).hasClass("smilies")) return;
			$(this).addClass("smilies");

			this.innerHTML = rep_smilies(this.innerHTML,0).replace(/&lt;3/g,"&#x2665;");

			initBBCodes();
		});
	}, 100);

	if (document.location.href.indexOf("page=messages") != -1) {
		$(document).ajaxSuccess(function(e,xhr,settings){
			if (settings.url.indexOf("page=showmessage") == -1) return;

			$(".overlayDiv > .showmessage").each(function(){
				var note = this.getElementsByClassName("note")[0];
				if (note && this.getElementsByClassName("melden").length > 0) {
					if ($(this).hasClass("smilies")) return;
					$(this).addClass("smilies");

					funcSmilies(this.getElementsByTagName("form")[0]);

					note.innerHTML = rep_smilies(note.innerHTML,0).replace(/&lt;3/g,"&#x2665;");

					initBBCodes();
				}
			});
		});
	} else if (document.location.href.indexOf("page=alliance") != -1) {
		$(document).ajaxSuccess(function(e,xhr,settings){
			if (settings.url.indexOf("page=allianceBroadcast") == -1) return;

			funcSmilies(document.forms[0]);
		});
	}

	$(document).ajaxSuccess(function(e,xhr,settings){
		if (settings.url.indexOf("page=writemessage") == -1) return;

		$(".overlayDiv > .writemessage").each(function(){
			if ($(this).hasClass("smilies")) return;
			$(this).addClass("smilies");

			funcSmilies(this.getElementsByTagName("form")[0]);
		});
	});
}).toString();

var script = document.createElement("script");
script.setAttribute("type","text/javascript");
script.text = addSmiley.toString() + "\n(" + strFunc + ")();";
document.body.appendChild(script);