FFL Chat Modifier

This userscript allows you to run the FFL LIVE chat within a tab in your browser and allows for some new BBCode!

目前為 2015-09-26 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         FFL Chat Modifier
// @namespace    http://fusionfalllegacy.com/
// @version      1.4
// @description  This userscript allows you to run the FFL LIVE chat within a tab in your browser and allows for some new BBCode!
// @author       L0L_Limewire
// @match        http://interact.modulatornetwork.com/forums/chat/index.php*
// @match        http://www.fusionfalllegacy.com/*
// @grant        none
// ==/UserScript==

// ADDED FEATURES LIST

// [textcolor=#COLOR IN HEX]message[/textcolor]
// [code]message[/code]
// [img]image url[/img]
// enabled opening the LIVE chat in a tab

// don't look at me, i don't regular javascript. dont cry to me when this script isnt pretty or up to ethical standards

// if the page has a 

// stop tab redirection

if(window.location.hostname === "www.fusionfalllegacy.com"){
    StartFusionModLIVE = function(){
        window.location = "http://interact.modulatornetwork.com/forums/chat/index.php";
    };
    return;
}

top = self; // im really really sorry
window.name = 'ModNetFMHQliveMainWindow'; // like super super sorry for this hacky patch

ReloadFMHQLive = function(){}; // i still wonder why exactly tabs arent allowed to this day

alert("Welcome to LIVE!"); // slight delay prevents redirection

// now for the real features

sound = new Audio("http://s1.vocaroo.com/media/download_temp/Vocaroo_s1i83BLxw0A0.mp3"); // you're welcome Professor

NaughtyWords = [ // avert your eyes, children!
    'bastard',
    'basstard',
    'basterd',
    'bassterd',
    'bas tard',
    'bass tard',
    'bas terd',
    'bass terd',
    'asshole',
    'asshoie',
    'assho1e',
    'assho!e',
    'ass',
    'azzhole',
    'azzhoie',
    'azzho1e',
    'azzho!e',
    'beer',
    'boob',
    'badb',
    'bitch',
    'cunt',
    'dammit',
    'damm!t',
    'damm1t',
    'dammlt',
    'damn',
    'dick',
    'd!ck',
    'd1ck',
    'dlck',
    'fuc',
    'fuk',
    'fuck',
    'fux',
    'nipple',
    'nude',
    'nudity',
    'p!ss',
    'p1ss',
    'penis',
    'pen!s',
    'pen1s',
    'piss',
    'puss',
    'sex',
    'shit',
    'sh!t',
    'sh1t',
    'shlt',
    'tits',
    'vagisil',
    'vagina',
    'arse',
    'hel',
    'hell',
    'bullass',
    'fvck',
    'twat',
    'jerkwad',
    'jack coco',
    'jackazz',
    'jack azz',
    'porn',
    'customass',
    'sasser',
    'sasst',
    'helpuffs',
    'cock',
    'faggot',
    'fagot',
    'fagot',
    'fagot',
    'fag',
    'nigger',
    'n!gger',
    'panty',
    'porm',
    'pr0n',
    'anal',
    'ccoco',
    'semen',
    'whore',
    'biggot',
    'chink',
    'clit',
    'vag',
    'slut',
    'skank',
    'hooker',
    'prostitute',
    'nigga',
    'thot',
    'hentai'
];

newButtons = [
    ["Color","Insert color : [textcolor=#HEXCOLOR]message[/textcolor]","textcolor"],
    ["Code","[code]script contents[/code]","code"],
    ["Image","[img]image url[/img]","img"]
];

replaceText = [ // for those who accidently say shit they dont mean to
    ["lmao","lmbo"],
    ["hella","hecka"],
    ["gdi","gosh darn it"],
    ["omfg","omg"]
];

ajaxChat.bbCodeTags = ['b','i','u','strike','quote','color','url','code','img','textcolor']; //add new bbcode and revive old bbcode
ajaxChat.settings.bbCodeImages = true; // enable images

onlineText = document.getElementById("onlineListContainer").firstElementChild;
buttonHolder = document.getElementById("bbCodeContainer");

var newButton;

for(newButton in newButtons){ // add new bbcode buttons
    newButton = newButtons[newButton];
    Button = document.createElement("input");
    Button.type = "button";
    Button.value = newButton[0];
    Button.title = newButton[1];
    Button.setAttribute("onclick","ajaxChat.insertBBCode('"+newButton[2]+"')");
    buttonHolder.appendChild(Button);
}

ajaxChat.replaceBBCodeCallback = function(str, p1, p2, p3) { // replace functions to allow for new features
	// Only replace predefined BBCode tags:
	if(!ajaxChat.inArray(ajaxChat.bbCodeTags, p1)) {
		return str;
	}
	// Avoid invalid XHTML (unclosed tags):
	if(ajaxChat.containsUnclosedTags(p3)) {
		return str;
	}	
	switch(p1) {
		case 'color':
			return ajaxChat.replaceBBCodeColor(p3, p2);
        case 'textcolor': // [color] tag but allows for use within nested colors such as 
            return ajaxChat.replaceBBCodeColor(p3,p2);
		case 'url':
			return ajaxChat.replaceBBCodeUrl(p3, p2);
		case 'quote':
			return ajaxChat.replaceBBCodeQuote(p3, p2);
		case 'u':
			return ajaxChat.replaceBBCodeUnderline(p3);
		case 'strike':
			return ajaxChat.replaceBBCodeStrike(p3);
		case 'img': // [img] tag
			return ajaxChat.replaceBBCodeImage(p3);
		default:
			return ajaxChat.replaceCustomBBCode(p1, p2, p3);
	}
};

ajaxChat.replaceBBCodeImage = function(url) { // function enabled
	var regExpUrl;
	regExpUrl = new RegExp(this.regExpMediaUrl,'');
	if(!url || !url.match(regExpUrl))
		return url;
	url = url.replace(/\s/gm, this.encodeText(' '));
	return	'<a href="'+url+'" onclick="window.open(this.href); return false;">'+'<img class="bbCodeImage" style="max-width:250px;" src="'+url+'" alt="Click to view full-size image." onload="ajaxChat.updateChatlistView();"/></a>';
};

ajaxChat.replaceBBCodeColor = function(content, attribute) { // color limitations removed
    if(this.settings.bbCodeColors) {
		return 	'<span style="color:'+ attribute + ';">'+ this.replaceBBCode(content)+ '</span>';
	}
	return content;
};

ajaxChat.replaceCustomText = function(text){
    var doAlert,index;
    doAlert = false; // do sound upon naughty word
    for(index in NaughtyWords){
        naughty = NaughtyWords[index];
        if(text.search(new RegExp('\\b'+naughty+'\\b','gi'))!=-1){
            doAlert = true; // enable sound playback
        }
        text = text.replace(new RegExp('\\b'+naughty+'\\b','gi'), 'coco'); // and then censor the word
    }
    if(doAlert === true){
        sound.play();
    }
    return text;
};

ajaxChat.insertBBCode = function(bbCode) { // custom bbcode button support
	switch(bbCode) {			
		case 'url':
			var url = prompt(this.lang.urlDialog, 'http://');
			if(url)
				this.insert('[url=' + url + ']', '[/url]');
			else
				this.dom.inputField.focus();
			break;
        case 'textcolor':
            var textcolor = prompt('What color? (in hex format)','#');
            if(textcolor)
                this.insert('[textcolor=' + textcolor + ']','[/textcolor]');
            else
                this.dom.inputField.focus();
            break;
		default:
			this.insert('[' + bbCode + ']', '[/' + bbCode + ']');		
	}
};

ajaxChat.handleOnlineUsers = function(userNodes) { // replace to update the user counter
	if(userNodes.length) {
        onlineText.textContent = "Online users : "+userNodes.length.toString(); // show member count
		var index,userID,userName,userRole,i,
			onlineUsers = [];
		for(i=0; i<userNodes.length; i++) {
			userID = userNodes[i].getAttribute('userID');
			userName = userNodes[i].firstChild ? userNodes[i].firstChild.nodeValue : '';
			userRole = userNodes[i].getAttribute('userRole');
			onlineUsers.push(userID);
			index = this.arraySearch(userID, this.usersList);
			if(index === false) {
				this.addUserToOnlineList(
					userID,
					userName,
					userRole
				);
			} else if(this.userNamesList[index] !== userName) {
				this.removeUserFromOnlineList(userID, index);
				this.addUserToOnlineList(
					userID,
					userName,
					userRole
				);
			}
		}
		// Clear the offline users from the online users list:
		for(i=0; i<this.usersList.length; i++) {
			if(!this.inArray(onlineUsers, this.usersList[i])) {
				this.removeUserFromOnlineList(this.usersList[i], i);
			}
		}	
		this.setOnlineListRowClasses();		
	}
    limewireNode = document.getElementById("ajaxChat_u_2140");
    if(limewireNode !== null){
        limewireNode.firstElementChild.style.color = "#eccc00"
    }   
};

ajaxChat.sendMessage = function(text) {
		text = text ? text : this.dom['inputField'].value;
		if(!text) {
			return;
		}
		text = this.parseInputMessage(text);
        for(wordIndex in replaceText){
            replaceArray = replaceText[wordIndex]
            text = text.replace(replaceArray[0],replaceArray[1])
        }
		if(text) {
			clearTimeout(this.timer);
			var message = 	'lastID='
							+ this.lastID
							+ '&text='
							+ this.encodeText(text);				
			this.makeRequest(this.ajaxURL,'POST',message);
		}
		this.dom['inputField'].value = '';
		this.dom['inputField'].focus();
		this.updateMessageLengthCounter();
	}