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. PLEASE PLEASE PLEASE PLEASE PLEEEASE click the ? button for information on how to install this script.

当前为 2016-01-12 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name FFL Chat Modifier
  3. // @namespace http://fusionfalllegacy.com/
  4. // @version 1.8.1
  5. // @description This userscript allows you to run the FFL LIVE chat within a tab in your browser and allows for some new BBCode. PLEASE PLEASE PLEASE PLEASE PLEEEASE click the ? button for information on how to install this script.
  6. // @author L0L_Limewire
  7. // @match http://interact.modulatornetwork.com/forums/chat/index.php*
  8. // @grant none
  9. // @run-at document-start
  10. // ==/UserScript==
  11.  
  12. // ADDED FEATURES LIST
  13.  
  14. // [textcolor=#COLOR IN HEX]message[/textcolor]
  15. // [code]message[/code]
  16. // <REMOVED> [img]image url[/img]
  17. // enabled opening the LIVE chat in a tab
  18.  
  19. // don't look at me, i don't do regular javascript. dont cry to me when this script isnt pretty or up to ethical standards
  20.  
  21. // stop tab redirection
  22.  
  23. ReloadFMHQLive = function(){}; // i still wonder why exactly tabs arent allowed to this day
  24.  
  25. // now for the real features
  26.  
  27. naughtySound = new Audio("http://s1.vocaroo.com/media/download_temp/Vocaroo_s1i83BLxw0A0.mp3"); // you're welcome Professor
  28.  
  29. Sounds = {}
  30.  
  31. for (i=0;i<10;i++){ // loop through and add sounds
  32. Sounds["sound_"+i.toString()] = new Audio("http://interact.modulatornetwork.com/forums/chat/sounds/sound_"+i.toString())
  33. }
  34.  
  35. ajaxChat.sounds = true // enables audio
  36.  
  37. NaughtyWords = [ // avert your eyes, children!
  38. 'bastard',
  39. 'basstard',
  40. 'basterd',
  41. 'bassterd',
  42. 'bas tard',
  43. 'bass tard',
  44. 'bas terd',
  45. 'bass terd',
  46. 'asshole',
  47. 'asshoie',
  48. 'assho1e',
  49. 'assho!e',
  50. 'ass',
  51. 'azzhole',
  52. 'azzhoie',
  53. 'azzho1e',
  54. 'azzho!e',
  55. 'beer',
  56. 'boob',
  57. 'badb',
  58. 'bitch',
  59. 'cunt',
  60. 'dammit',
  61. 'damm!t',
  62. 'damm1t',
  63. 'dammlt',
  64. 'damn',
  65. 'dick',
  66. 'd!ck',
  67. 'd1ck',
  68. 'dlck',
  69. 'fuc',
  70. 'fuk',
  71. 'fuck',
  72. 'fux',
  73. 'nipple',
  74. 'nude',
  75. 'nudity',
  76. 'p!ss',
  77. 'p1ss',
  78. 'penis',
  79. 'pen!s',
  80. 'pen1s',
  81. 'piss',
  82. 'puss',
  83. 'sex',
  84. 'shit',
  85. 'sh!t',
  86. 'sh1t',
  87. 'shlt',
  88. 'tits',
  89. 'vagisil',
  90. 'vagina',
  91. 'arse',
  92. 'hel',
  93. 'hell',
  94. 'bullass',
  95. 'fvck',
  96. 'twat',
  97. 'jerkwad',
  98. 'jack coco',
  99. 'jackazz',
  100. 'jack azz',
  101. 'porn',
  102. 'customass',
  103. 'sasser',
  104. 'sasst',
  105. 'helpuffs',
  106. 'cock',
  107. 'faggot',
  108. 'fagot',
  109. 'fagot',
  110. 'fagot',
  111. 'fag',
  112. 'nigger',
  113. 'n!gger',
  114. 'panty',
  115. 'porm',
  116. 'pr0n',
  117. 'anal',
  118. 'ccoco',
  119. 'semen',
  120. 'whore',
  121. 'biggot',
  122. 'chink',
  123. 'clit',
  124. 'vag',
  125. 'slut',
  126. 'skank',
  127. 'hooker',
  128. 'prostitute',
  129. 'nigga',
  130. 'thot',
  131. 'hentai'
  132. ];
  133.  
  134. newButtons = [
  135. ["Color","Insert color : [textcolor=#HEXCOLOR]message[/textcolor]","textcolor"],
  136. ["Code","[code]script contents[/code]","code"],
  137. ["Image","[img]image url[/img]","img"]
  138. ];
  139.  
  140. replaceText = [ // for those who accidently say shit they dont mean to
  141. ["lmao","lmbo"],
  142. ["hella","hecka"],
  143. ["gdi","gosh darn it"],
  144. ["omfg","omg"],
  145. ["hell","heck"],
  146. ["damn","darn"]
  147. ];
  148.  
  149. ajaxChat.bbCodeTags = ['b','i','u','strike','quote','color','url','code','img','textcolor']; //add new bbcode and revive old bbcode
  150. ajaxChat.settings.bbCodeImages = true; // enable images
  151.  
  152. onlineText = document.getElementById("onlineListContainer").firstElementChild;
  153. buttonHolder = document.getElementById("bbCodeContainer");
  154.  
  155. var newButton;
  156.  
  157. for(newButton in newButtons){ // add new bbcode buttons
  158. newButton = newButtons[newButton];
  159. Button = document.createElement("input");
  160. Button.type = "button";
  161. Button.value = newButton[0];
  162. Button.title = newButton[1];
  163. Button.setAttribute("onclick","ajaxChat.insertBBCode('"+newButton[2]+"')");
  164. buttonHolder.appendChild(Button);
  165. }
  166.  
  167. ajaxChat.replaceBBCodeCallback = function(str, p1, p2, p3) { // replace functions to allow for new features
  168. // Only replace predefined BBCode tags:
  169. if(!ajaxChat.inArray(ajaxChat.bbCodeTags, p1)) {
  170. return str;
  171. }
  172. // Avoid invalid XHTML (unclosed tags):
  173. if(ajaxChat.containsUnclosedTags(p3)) {
  174. return str;
  175. }
  176. switch(p1) {
  177. case 'color':
  178. return ajaxChat.replaceBBCodeColor(p3, p2);
  179. case 'textcolor': // [color] tag but allows for use within nested colors such as
  180. return ajaxChat.replaceBBCodeColor(p3,p2);
  181. case 'url':
  182. return ajaxChat.replaceBBCodeUrl(p3, p2);
  183. case 'quote':
  184. return ajaxChat.replaceBBCodeQuote(p3, p2);
  185. case 'u':
  186. return ajaxChat.replaceBBCodeUnderline(p3);
  187. case 'strike':
  188. return ajaxChat.replaceBBCodeStrike(p3);
  189. case 'img': // [img] tag
  190. return ajaxChat.replaceBBCodeImage(p3);
  191. default:
  192. return ajaxChat.replaceCustomBBCode(p1, p2, p3);
  193. }
  194. };
  195.  
  196. //ajaxChat.replaceBBCodeImage = function(url) { // function enabled
  197. // var regExpUrl;
  198. // regExpUrl = new RegExp(this.regExpMediaUrl,'');
  199. // if(!url || !url.match(regExpUrl))
  200. // return url;
  201. // url = url.replace(/\s/gm, this.encodeText(' '));
  202. // 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>';
  203. //};
  204.  
  205. ajaxChat.replaceBBCodeColor = function(content, attribute) { // color limitations removed
  206. if(this.settings.bbCodeColors) {
  207. return '<span style="color:'+ attribute + ';">'+ this.replaceBBCode(content)+ '</span>';
  208. }
  209. return content;
  210. };
  211.  
  212. ajaxChat.replaceCustomText = function(text){
  213. var doAlert,index;
  214. doAlert = false; // do sound upon naughty word
  215. for(index in NaughtyWords){
  216. naughty = NaughtyWords[index];
  217. if(text.search(new RegExp('\\b'+naughty+'\\b','gi'))!=-1){
  218. doAlert = true; // enable sound playback
  219. }
  220. text = text.replace(new RegExp('\\b'+naughty+'\\b','gi'), 'coco'); // and then censor the word
  221. }
  222. if(doAlert === true){
  223. naughtySound.play();
  224. }
  225. return text;
  226. };
  227.  
  228. ajaxChat.insertBBCode = function(bbCode) { // custom bbcode button support
  229. switch(bbCode) {
  230. case 'url':
  231. var url = prompt(this.lang.urlDialog, 'http://');
  232. if(url)
  233. this.insert('[url=' + url + ']', '[/url]');
  234. else
  235. this.dom.inputField.focus();
  236. break;
  237. case 'textcolor':
  238. var textcolor = prompt('What color? (in hex format)','#');
  239. if(textcolor)
  240. this.insert('[textcolor=' + textcolor + ']','[/textcolor]');
  241. else
  242. this.dom.inputField.focus();
  243. break;
  244. default:
  245. this.insert('[' + bbCode + ']', '[/' + bbCode + ']');
  246. }
  247. };
  248.  
  249. ajaxChat.handleOnlineUsers = function(userNodes) { // replace to update the user counter
  250. if(userNodes.length) {
  251. onlineText.textContent = "Online users : "+userNodes.length.toString(); // show member count
  252. var index,userID,userName,userRole,i,
  253. onlineUsers = [];
  254. for(i=0; i<userNodes.length; i++) {
  255. userID = userNodes[i].getAttribute('userID');
  256. userName = userNodes[i].firstChild ? userNodes[i].firstChild.nodeValue : '';
  257. userRole = userNodes[i].getAttribute('userRole');
  258. onlineUsers.push(userID);
  259. index = this.arraySearch(userID, this.usersList);
  260. if(index === false) {
  261. this.addUserToOnlineList(
  262. userID,
  263. userName,
  264. userRole
  265. );
  266. } else if(this.userNamesList[index] !== userName) {
  267. this.removeUserFromOnlineList(userID, index);
  268. this.addUserToOnlineList(
  269. userID,
  270. userName,
  271. userRole
  272. );
  273. }
  274. }
  275. // Clear the offline users from the online users list:
  276. for(i=0; i<this.usersList.length; i++) {
  277. if(!this.inArray(onlineUsers, this.usersList[i])) {
  278. this.removeUserFromOnlineList(this.usersList[i], i);
  279. }
  280. }
  281. this.setOnlineListRowClasses();
  282. }
  283. limewireNode = document.getElementById("ajaxChat_u_2140");
  284. if(limewireNode !== null){
  285. limewireNode.firstElementChild.style.color = "#eccc00";
  286. }
  287. };
  288.  
  289. ajaxChat.sendMessage = function(text) {
  290. text = text ? text : this.dom.inputField.value;
  291. if(!text) {
  292. return;
  293. }
  294. var wordIndex;
  295. text = this.parseInputMessage(text);
  296. for(wordIndex in replaceText){
  297. replaceArray = replaceText[wordIndex];
  298. text = text.replace(new RegExp('\\b'+replaceArray[0]+'\\b',"gi"),replaceArray[1]);
  299. }
  300. if(text) {
  301. clearTimeout(this.timer);
  302. var message = 'lastID=' + this.lastID + '&text=' + this.encodeText(text);
  303. this.makeRequest(this.ajaxURL,'POST',message);
  304. }
  305. this.dom.inputField.value = '';
  306. this.dom.inputField.focus();
  307. this.updateMessageLengthCounter();
  308. };
  309.  
  310. ajaxChat.playSound = function(sound){ // lame way to implement sounds - i don't use javascript often
  311. Sounds[sound].play()
  312. };
  313.  
  314. ajaxChat.playSoundOnNewMessage = function(dateObject, userID, userName, userRole, messageID, messageText, channelID, ip) {
  315. if(this.settings.audio && this.sounds && this.lastID && !this.channelSwitch) {
  316. switch(userID) {
  317. case this.chatBotID:
  318. var messageParts = messageText.split(' ', 1);
  319. switch(messageParts[0]) {
  320. case '/login':
  321. this.playSound('sound_3');
  322. break;
  323. case '/channelEnter':
  324. //this.playSound('sound_7');
  325. break;
  326. case '/logout':
  327. this.playSound('sound_4');
  328. break;
  329. case '/channelLeave':
  330. //this.playSound('sound_8');
  331. break;
  332. case '/kick':
  333. //this.playSound('sound_9');
  334. break;
  335. case '/error':
  336. this.playSound('sound_6');
  337. break;
  338. default:
  339. this.playSound('sound_5');
  340. }
  341. break;
  342. case this.userID:
  343. this.playSound('sound_2');
  344. break;
  345. default:
  346. this.playSound('sound_1');
  347. break;
  348. }
  349. }
  350. };
  351.  
  352. // patch the scroll issue
  353.  
  354. ajaxChat.updateChatlistView = function(){
  355. if(this.dom['chatList'].childNodes && this.settings['maxMessages']) {
  356. while(this.dom['chatList'].childNodes.length > this.settings['maxMessages']) {
  357. this.dom['chatList'].removeChild(this.dom['chatList'].firstChild);
  358. }
  359. }
  360. if(this.settings['autoScroll']) {
  361. this.dom['chatList'].scrollTop = 1e+40 // WE'RE NOT AIMING FOR THE TRUCK
  362. }
  363. }