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-27 提交的版本,查看 最新版本

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