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