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