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.

当前为 2015-10-05 提交的版本,查看 最新版本

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