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

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