NGU SBMod

Shoutbox plugin that adds several features

当前为 2017-01-20 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name NGU SBMod
  3. // @namespace http://www.nextgenupdate.com
  4. // @description Shoutbox plugin that adds several features
  5. // @include /^https?:\/\/www\.nextgenupdate\.com\/forums\/infernoshout\.php\?do=detach$/
  6. // @include /^https?:\/\/www\.nextgenupdate\.com\/forums\/(forumhome|index)\.php$/
  7. // @include /^https?:\/\/www\.nextgenupdate\.com\/forums.?.?$/
  8. // @version 1.91
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  13. //////// variables / arrays / data //////
  14.  
  15.  
  16. var saveshouts = 0;
  17. var happyHourBG = 'http://f.cl.ly/items/2x2u1r2w372V0m3G2o3Y/rain.gif';
  18. var happyHourText = 'HAPPY HOUR';
  19. var happyHourTextColor = 'rgba(255,255,255,1.0)';
  20. var sbm_smilies_hidden = {
  21. ":mario:": "http://www.nextgenupdate.com/forums/images/mario.gif",
  22. ":trolldad:": "images/smilies/trolldad.png",
  23. ":ca:": "http://www.nextgenupdate.com/forums/images/smilies/challengeaccepted.jpg",
  24. ":okay:": "images/smilies/okay.png",
  25. ":fa:": "images/smilies/ForeverAlone.png",
  26. ":lol:": "images/smilies/LOLguy.png",
  27. ":carling:": "http://www.nextgenupdate.com/forums/images/smilies/troll.gif",
  28. ":boss:": "http://www.nextgenupdate.com/forums/images/smilies/memes/likeaboss.jpg",
  29. ":yds:": "images/smilies/u%20dont%20say.png",
  30. ":fyea:": "images/smilies/memes/fyea.png",
  31. "yuno": "images/smilies/memes/yuno.png",
  32. ":dumb:": "http://www.nextgenupdate.com/forums/images/smilies/memes/Dumb.png",
  33. "=Z": "http://www.nextgenupdate.com/forums/images/smilies/Z=.jpg",
  34. ":megusta:": "images/smilies/memes/Megusta.png",
  35. ":ohgodwhy:": "http://www.nextgenupdate.com/forums/images/smilies/memes/oh-god-why1.jpg",
  36. ":|": "http://www.nextgenupdate.com/forums/images/smilies/pokerfacee.jpg",
  37. ":ha!:": "http://www.nextgenupdate.com/forums/images/smilies/memes/meme-aww.jpg",
  38. ":FU:": "http://www.nextgenupdate.com/forums/images/smilies/FFFFFUUU.gif",
  39. ":blank:": "http://www.nextgenupdate.com/forums/images/smilies/memes/vish.jpg",
  40. "^^": "http://www.nextgenupdate.com/forums/images/smilies/memes/%5E%5E.jpg",
  41. ":think:": "http://www.nextgenupdate.com/forums/images/smilies/memes/=.jpg",
  42. ":satisfied:": "http://www.nextgenupdate.com/forums/images/smilies/memes/download.jpg",
  43. ":happyguy:": "http://www.nextgenupdate.com/forums/images/smilies/memes//(=.jpg",
  44. ":happycry:": "http://www.nextgenupdate.com/forums/images/smilies/HappyCry.png",
  45. "D:>": "http://www.nextgenupdate.com/forums/images/smilies/memes/D=.jpg",
  46. "<:D": "http://www.nextgenupdate.com/forums/images/smilies/=D.jpg",
  47. ">:<": "http://www.nextgenupdate.com/forums/images/smilies/memes/=SS.jpg"
  48. };
  49. var sbm_smilies_elite = {
  50. ":wtf:": "images/smilies/wtf.gif",
  51. ";D": "images/smilies/wink2.png",
  52. ":nyan:": "images/smilies/nyan.gif",
  53. ":banhamma:": "images/smilies/banhamma.gif",
  54. ":run:": "images/smilies/troll_run.gif",
  55. ":slowpoke:": "images/smilies/slowpoke.png",
  56. ":fah:": "images/smilies/fah.png",
  57. ":alpaca:": "images/smilies/alpaca1.gif",
  58. ":mudkip:": "images/smilies/Mudkip.png",
  59. ":dunce:": "images/smilies/new%202/sFun_dunce.gif",
  60. ":hug:": "images/smilies/newset1/saril.gif",
  61. ":wub:": "images/smilies/newset1/wub.gif",
  62. ":luv:": "images/smilies/newset1/asik.gif",
  63. ":monkey:": "images/smilies/monkey.gif",
  64. ":dance:": "images/smilies/badger.gif",
  65. ":drink:": "images/smilies/drink.gif",
  66. ":dealwiththeobscurename:": "images/smilies/deal.gif",
  67. ":walt:": "images/heisenberg.png",
  68. ":nope:": "images/nope.png"
  69. };
  70. var sbm_smilies_weed = {
  71. ":high:": "images/smilies/weed1.gif",
  72. ":higher:": "images/smilies/weed2.gif",
  73. ":ripped:": "images/smilies/weed3.gif",
  74. ":blazed:": "images/smilies/weed4.gif",
  75. ":puffpuffpass:": "http://www.nextgenupdate.com/forums/images/smilies/weed5.gif",
  76. ":bongrip:": "http://www.nextgenupdate.com/forums/images/smilies/weed6.gif",
  77. ":bongripped:": "images/smilies/weed7.jpg",
  78. ":carlaang:": "images/smilies/weed8.png",
  79. ":enzooo:": "images/smilies/weed9.png",
  80. ":reaperrr:": "images/smilies/weed10.png",
  81. ":yunosmoke:": "images/smilies/weed11.gif",
  82. ":outieee:": "images/smilies/weed12.png",
  83. ":drackosss:": "images/smilies/weed13.png"
  84. };
  85. var spam = false;
  86. //////// end of variables / arrays / data //////
  87. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  88. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  89. //////// local storage functions - edited functions taken from https://gist.githubusercontent.com/arantius/3123124/raw/grant-none-shim.js //////
  90.  
  91. function sbm_addStyle(aCss)
  92. {
  93. 'use strict';
  94. var head = document.getElementsByTagName('head')[0];
  95. if (head)
  96. {
  97. var style = document.createElement('style');
  98. style.setAttribute('type', 'text/css');
  99. style.textContent = aCss;
  100. head.appendChild(style);
  101. return style;
  102. }
  103. return null;
  104. }
  105.  
  106. function sbm_deleteValue(aKey)
  107. {
  108. 'use strict';
  109. localStorage.removeItem('ngu_sbmod_' + aKey);
  110. }
  111.  
  112. function sbm_getValue(aKey, aDefault)
  113. {
  114. 'use strict';
  115. var val = localStorage.getItem('ngu_sbmod_' + aKey);
  116. if (null === val && 'undefined' != typeof aDefault)
  117. {
  118. return aDefault;
  119. }
  120. return val;
  121. }
  122.  
  123. function sbm_setValue(aKey, aVal)
  124. {
  125. 'use strict';
  126. localStorage.setItem('ngu_sbmod_' + aKey, aVal);
  127. }
  128.  
  129. //////// end of local storage functions //////
  130. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  131. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  132. //////// misc functions //////
  133.  
  134. // shout function
  135. function jsShout(message)
  136. {
  137. //iboxoshouts.set_loader('');
  138. iboxoshouts.shout.ajax = new vB_AJAX_Handler(true);
  139. iboxoshouts.shout.ajax.onreadystatechange(InfernoShoutboxControl.shout_posted);
  140. iboxoshouts.shout.ajax.send('infernoshout.php', 'do=shout&message='+message);
  141. //iboxoshouts.clear();
  142. }
  143.  
  144. function numberWithCommas(x)// http://stackoverflow.com/a/2901298
  145. {
  146. return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
  147. }
  148.  
  149. // return username and userid from the onclick attribute
  150. function userDetailsFromOnclick(input)
  151. {
  152. // input string will look like this:
  153. // return InfernoShoutboxControl.open_pm_tab('pm_1234', 'User with ID 1234');
  154. //
  155. // so first remove this from the beginning:
  156. // return InfernoShoutboxControl.open_pm_tab('pm_
  157. //
  158. // then remove this from the end:
  159. // ');
  160. //
  161. // then split on this:
  162. // ', '
  163. //
  164. // then put it all on one line and return it, this should work for any user, except one that has ', ' in the username
  165. // if it's not obvious, this returns an array
  166. //return input.replace('return InfernoShoutboxControl.open_pm_tab(\'pm_', '').replace('\');', '').split('\', \'',2);
  167. return input.replace('return sbmodDropdownMenu(\'pm_', '').replace('\');', '').split('\', \'',2);
  168. }
  169.  
  170. // return userid from profile link
  171. function userIdFromHref(input)
  172. {
  173. var input2 = input.split("=",2);
  174. return input2[1];
  175. }
  176.  
  177. function getUserPrefixImages(e)
  178. {
  179. var o = [];
  180. var c = 0;
  181. var nodes = e.parentNode.childNodes;
  182. for (var i = 0; i < nodes.length; i++)
  183. {
  184. var z = new Object();
  185. if (nodes[i] == e)
  186. {
  187. break;
  188. }
  189. else if (nodes[i].tagName == "IMG")
  190. {
  191. z.src = nodes[i].getAttribute('src');
  192. if (nodes[i].getAttribute('style'))
  193. {
  194. z.style = nodes[i].getAttribute('style');
  195. }
  196. o[i] = z;
  197. c++;
  198. }
  199. else if (nodes[i].tagName == "A")
  200. {
  201. var cnodes = nodes[i].childNodes;
  202. for (var j = 0; j < cnodes.length; j++)
  203. {
  204. if (cnodes[j].tagName == "IMG")
  205. {
  206. z.src = cnodes[j].getAttribute('src');
  207. if (cnodes[j].getAttribute('style'))
  208. {
  209. z.style = cnodes[j].getAttribute('style');
  210. }
  211. o[i] = z;
  212. c++;
  213. }
  214. }
  215. }
  216. }
  217. if (c === 0)
  218. {
  219. return null;
  220. }
  221. else
  222. {
  223. return o;
  224. }
  225. }
  226.  
  227. function findUserElement(e)
  228. {
  229. while (e.parentNode)
  230. {
  231. if (e.tagName == "A")
  232. {
  233. var h = e.getAttribute('href');
  234. if (h)
  235. {
  236. if (h == '#' || h.indexOf('member.php?u=') > -1)
  237. {
  238. return e;
  239. }
  240. }
  241. }
  242. e = e.parentNode;
  243. }
  244. return null;
  245. }
  246.  
  247. // enable or disable happyhour css (seperate function so it can be called on startup)
  248. function doHappyHourCSS(enable)
  249. {
  250. if (enable)
  251. sbm_addStyle('div [style="padding-top: 1px; padding-bottom: 1px;"]>.hidden-phone{display: none !important;}div [style="padding-top: 1px; padding-bottom: 1px;"]:before{content: "'+happyHourText+'" !important;white-space: pre !important;color: '+happyHourTextColor+' !important;padding-left: 2px !important;padding-right: 2px !important;background-image: url("'+happyHourBG+'") !important;font-weight: bold !important}');
  252. else
  253. sbm_addStyle('div [style="padding-top: 1px; padding-bottom: 1px;"]>.hidden-phone{display: initial !important;}div [style="padding-top: 1px; padding-bottom: 1px;"]:before{content: none !important;white-space: none !important;color: none !important;padding-left: none !important;padding-right: none !important;background-image: none !important;font-weight: none !important}');
  254. }
  255.  
  256. // set idle timeout
  257. function setIdletime(time)
  258. {
  259. InfernoShoutboxControl.idletimelimit = time;
  260. sbm_setValue("int_idletimelimit",time);
  261. if (time == -1)
  262. {
  263. document.getElementById("sbm_dropdown_idletimelimit").innerHTML = 'Set Idletime (disabled)';
  264. iboxoshouts.show_notice('Idle timeout disabled');
  265. }
  266. else
  267. {
  268. document.getElementById("sbm_dropdown_idletimelimit").innerHTML = 'Set Idletime ('+time+')';
  269. iboxoshouts.show_notice('Idle timeout set to '+time+' seconds');
  270. }
  271. }
  272.  
  273. // js prompt for idle timeout
  274. function promptIdletime()
  275. {
  276. var newIdletime = prompt("Enter idle timeout in seconds (-1 disables)",InfernoShoutboxControl.idletimelimit);
  277. if (newIdletime)
  278. {
  279. setIdletime(newIdletime);
  280. }
  281. }
  282.  
  283. sbmodDropdownMenu = function(pmid, username)
  284. {
  285. // this actually does nothing at the moment
  286. //
  287. // ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  288. // ░░░░░░░░░░░░░▄▄▄▄▄▄▄░░░░░░░░░
  289. // ░░░░░░░░░▄▀▀▀░░░░░░░▀▄░░░░░░░
  290. // ░░░░░░░▄▀░░░░░░░░░░░░▀▄░░░░░░
  291. // ░░░░░░▄▀░░░░░░░░░░▄▀▀▄▀▄░░░░░
  292. // ░░░░▄▀░░░░░░░░░░▄▀░░██▄▀▄░░░░
  293. // ░░░▄▀░░▄▀▀▀▄░░░░█░░░▀▀░█▀▄░░░
  294. // ░░░█░░█▄▄░░░█░░░▀▄░░░░░▐░█░░░
  295. // ░░▐▌░░█▀▀░░▄▀░░░░░▀▄▄▄▄▀░░█░░
  296. // ░░▐▌░░█░░░▄▀░░░░░░░░░░░░░░█░░
  297. // ░░▐▌░░░▀▀▀░░░░░░░░░░░░░░░░▐▌░
  298. // ░░▐▌░░░░░░░░░░░░░░░▄░░░░░░▐▌░
  299. // ░░▐▌░░░░░░░░░▄░░░░░█░░░░░░▐▌░
  300. // ░░░█░░░░░░░░░▀█▄░░▄█░░░░░░▐▌░
  301. // ░░░▐▌░░░░░░░░░░▀▀▀▀░░░░░░░▐▌░
  302. // ░░░░█░░░░░░░░░░░░░░░░░░░░░█░░
  303. // ░░░░▐▌▀▄░░░░░░░░░░░░░░░░░▐▌░░
  304. // ░░░░░█░░▀░░░░░░░░░░░░░░░░▀░░░
  305. // ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  306. };
  307.  
  308. killSpam = function(msg)
  309. {
  310. if (spam)
  311. {
  312. clearInterval(leSBSpam);
  313. iboxoshouts.show_notice(msg);
  314. spam = false;
  315. }
  316. };
  317.  
  318. //////// end of misc functions //////
  319. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  320. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  321. //////// dropdown menu functions //////
  322.  
  323. function dropdownToggleItemText(varName,itemtext)
  324. {
  325. if (sbm_getValue(varName) == "enabled")
  326. {
  327. return '☒ ' + itemtext;
  328. }
  329. else
  330. {
  331. return '☐ ' + itemtext;
  332. }
  333. }
  334.  
  335. function toggleDropdownElement(varName,elementId,elementText)
  336. {
  337. if (sbm_getValue(varName) == "enabled")
  338. {
  339. iboxoshouts.show_notice(elementText + ' Disabled');
  340. sbm_setValue(varName,"disabled");
  341. }
  342. else
  343. {
  344. iboxoshouts.show_notice(elementText + ' Enabled');
  345. sbm_setValue(varName,"enabled");
  346. }
  347. if (elementId)
  348. {
  349. document.getElementById(elementId).innerHTML = dropdownToggleItemText(varName,elementText);
  350. }
  351. }
  352.  
  353. function addOptionsDropdownItems()
  354. {
  355. var newsbOptionsDropdown = '<li><a id="sbm_dropdown_idletimelimit" style="cursor: pointer;">Set Idletime ('+sbm_getValue("int_idletimelimit")+')</a></li>';
  356. newsbOptionsDropdown += '<li><a id="sbm_dropdown_happyhour" style="cursor: pointer;">'+dropdownToggleItemText("bool_happyhour","Happy Hour")+'</a></li>';
  357. newsbOptionsDropdown += '<li><a id="sbm_dropdown_smilies_hidden" style="cursor: pointer;">'+dropdownToggleItemText("bool_smilies_hidden","Hidden Smilies")+'</a></li>';
  358. newsbOptionsDropdown += '<li><a id="sbm_dropdown_smilies_elite" style="cursor: pointer;">'+dropdownToggleItemText("bool_smilies_elite","Elite Smilies")+'</a></li>';
  359. newsbOptionsDropdown += '<li><a id="sbm_dropdown_smilies_weed" style="cursor: pointer;">'+dropdownToggleItemText("bool_smilies_weed","Weed Smilies")+'</a></li>';
  360. newsbOptionsDropdown += '<li><a id="sbm_dropdown_smilies_fake" style="cursor: pointer;">'+dropdownToggleItemText("bool_smilies_fake","Fake Smilies")+'</a></li>';
  361. newsbOptionsDropdown += '<li><div style="width: 100%; height: 1px; border: 0; background-color: rgba(128,128,128,0.8); margin-top: 0; margin-bottom: 0;"></div></li>';
  362.  
  363. // get the default dropdown menu element
  364. var sbOptionsDropdown = document.getElementsByClassName("shoutbox_dropdown_s");
  365.  
  366. // append html with new menu items
  367. sbOptionsDropdown[0].innerHTML += newsbOptionsDropdown;
  368.  
  369. // add click event listeners
  370. document.getElementById('sbm_dropdown_idletimelimit').addEventListener("click",function(){
  371. var newIdletime = prompt("Enter idle timeout in seconds (-1 disables)",InfernoShoutboxControl.idletimelimit);
  372. if (newIdletime)
  373. {
  374. setIdletime(newIdletime);
  375. }
  376. });
  377. document.getElementById('sbm_dropdown_happyhour').addEventListener('click',function(){
  378. toggleDropdownElement("bool_happyhour","sbm_dropdown_happyhour","Happy Hour");
  379. if (sbm_getValue("bool_happyhour") == "enabled")
  380. {
  381. doHappyHourCSS(true);
  382. }
  383. else
  384. {
  385. doHappyHourCSS(false);
  386. }
  387. });
  388. document.getElementById('sbm_dropdown_smilies_hidden').addEventListener('click',function(){
  389. toggleDropdownElement("bool_smilies_hidden","sbm_dropdown_smilies_hidden","Hidden Smilies");
  390. });
  391. document.getElementById('sbm_dropdown_smilies_elite').addEventListener('click',function(){
  392. toggleDropdownElement("bool_smilies_elite","sbm_dropdown_smilies_elite","Elite Smilies");
  393. });
  394. document.getElementById('sbm_dropdown_smilies_weed').addEventListener('click',function(){
  395. toggleDropdownElement("bool_smilies_weed","sbm_dropdown_smilies_weed","Weed Smilies");
  396. });
  397. document.getElementById('sbm_dropdown_smilies_fake').addEventListener('click',function(){
  398. toggleDropdownElement("bool_smilies_fake","sbm_dropdown_smilies_fake","Fake Smilies");
  399. });
  400. var sbMenuLinks = JSON.parse(sbm_getValue("json_quicklinks"));
  401.  
  402. // loop through the object of links and create / config / add elements
  403. for(var i in sbMenuLinks)
  404. {
  405. // create li
  406. var menuLi = document.createElement("li");
  407. // create a
  408. var menuA = document.createElement("a");
  409. // set a style="cursor: pointer;"
  410. menuA.style.cursor = "pointer";
  411. // set a href to the link in the object
  412. menuA.href = sbMenuLinks[i];
  413. // set target to open in new tab
  414. menuA.target = '_blank';
  415. // create text for link from the object
  416. menuText = document.createTextNode(i);
  417. // append the created a element with the link text
  418. menuA.appendChild(menuText);
  419. // append the created li element with the created a element
  420. menuLi.appendChild(menuA);
  421. // append the dropdown menu with the final element
  422. sbOptionsDropdown[0].appendChild(menuLi);
  423. }
  424. }
  425.  
  426. //////// end of dropdown menu functions //////
  427. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  428. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  429. //////// settings popup functions //////
  430.  
  431. function addToSettings_Smilies()
  432. {
  433. // get object from storage
  434. var oSmil = JSON.parse(sbm_getValue("json_smilies_fake"));
  435. // get the target element
  436. var sbOpts = document.getElementById("ngusb-options");
  437. if (!document.getElementById("sbm_settings_tab_fakesmilies"))// check if tab has already been created
  438. {
  439. // create the new tab
  440. var sbm_jsv_tab_fakesmilies = document.createElement("li");
  441. sbm_jsv_tab_fakesmilies.id = 'sbm_settings_tab_fakesmilies';
  442. sbm_jsv_tab_fakesmilies.innerHTML = '<a href="#sbm_settings_content_fakesmilies" data-toggle="tab">Fake Smilies</a>';
  443. // append the new tab to the target element
  444. sbOpts.childNodes[3].childNodes[1].appendChild(sbm_jsv_tab_fakesmilies);
  445. }
  446. if (!document.getElementById("sbm_settings_content_fakesmilies"))// check if content element has already been created
  447. {
  448. // content doesn't exist - create new content element
  449. var sbm_jsv_content_fakesmilies = document.createElement("div");
  450. sbm_jsv_content_fakesmilies.className = 'tab-pane';
  451. sbm_jsv_content_fakesmilies.id = 'sbm_settings_content_fakesmilies';
  452. sbm_jsv_content_fakesmilies.style.maxHeight = '300px';
  453. }
  454. else
  455. {
  456. // content exists - just get the content element so it can be updated
  457. var sbm_jsv_content_fakesmilies = document.getElementById("sbm_settings_content_fakesmilies");
  458. }
  459. // a whole bunch of html to make / update the content
  460. var sbm_jsv_content_innerhtml_fakesmilies = '<div class="form-horizontal"><b>Existing Smilies</b> (leave any field blank to delete)<br><br>';
  461. // loop through object and add row(s) of pre-filled elements using stored data
  462. for(var z in oSmil)
  463. {
  464. sbm_jsv_content_innerhtml_fakesmilies += '<div class="row">';
  465. sbm_jsv_content_innerhtml_fakesmilies += '<div class="control-group span2">';
  466. sbm_jsv_content_innerhtml_fakesmilies += '<label class="control-label" for="code" style="width: 30px;">Code:</label>';
  467. sbm_jsv_content_innerhtml_fakesmilies += '<div class="controls">';
  468. sbm_jsv_content_innerhtml_fakesmilies += '<input class="span2" type="text" size="50" id="code" name="smilies[code][]" value="'+z+'" style="width: 80px; margin-left: -120px;">';
  469. sbm_jsv_content_innerhtml_fakesmilies += '</div>';
  470. sbm_jsv_content_innerhtml_fakesmilies += '</div>';
  471. sbm_jsv_content_innerhtml_fakesmilies += '<div class="control-group span2">';
  472. sbm_jsv_content_innerhtml_fakesmilies += '<label class="control-label" for="url" style="width: 30px;">Url:</label>';
  473. sbm_jsv_content_innerhtml_fakesmilies += '<div class="controls">';
  474. sbm_jsv_content_innerhtml_fakesmilies += '<input class="span2" type="text" size="50" id="url" name="smilies[url][]" value="'+oSmil[z]+'" style="width: 360px; margin-left: -120px;">';
  475. sbm_jsv_content_innerhtml_fakesmilies += '</div>';
  476. sbm_jsv_content_innerhtml_fakesmilies += '</div>';
  477. sbm_jsv_content_innerhtml_fakesmilies += '</div>';
  478. }
  479. // more html
  480. sbm_jsv_content_innerhtml_fakesmilies += '<b>Add New Smilies</b><br><br>';
  481. // add some row(s) of empty fields for additions
  482. for(var h = 0; h < 2; h++)
  483. {
  484. sbm_jsv_content_innerhtml_fakesmilies += '<div class="row">';
  485. sbm_jsv_content_innerhtml_fakesmilies += '<div class="control-group span2">';
  486. sbm_jsv_content_innerhtml_fakesmilies += '<label class="control-label" for="code" style="width: 30px;">Code:</label>';
  487. sbm_jsv_content_innerhtml_fakesmilies += '<div class="controls">';
  488. sbm_jsv_content_innerhtml_fakesmilies += '<input type="text" size="50" id="code" name="smilies[code][]" value="" style="width: 80px; margin-left: -120px;">';
  489. sbm_jsv_content_innerhtml_fakesmilies += '</div>';
  490. sbm_jsv_content_innerhtml_fakesmilies += '</div>';
  491. sbm_jsv_content_innerhtml_fakesmilies += '<div class="control-group span2">';
  492. sbm_jsv_content_innerhtml_fakesmilies += '<label class="control-label" for="url" style="width: 30px;">Url:</label>';
  493. sbm_jsv_content_innerhtml_fakesmilies += '<div class="controls">';
  494. sbm_jsv_content_innerhtml_fakesmilies += '<input type="text" size="50" id="url" name="smilies[url][]" value="" style="width: 360px; margin-left: -120px;">';
  495. sbm_jsv_content_innerhtml_fakesmilies += '</div>';
  496. sbm_jsv_content_innerhtml_fakesmilies += '</div>';
  497. sbm_jsv_content_innerhtml_fakesmilies += '</div>';
  498. }
  499. // end of html
  500. sbm_jsv_content_innerhtml_fakesmilies += '<input value="Save Settings" type="submit" class="btn btn-primary" id="sbm_settings_save_fakesmilies"></div>';
  501. // set the html of the content element
  502. sbm_jsv_content_fakesmilies.innerHTML = sbm_jsv_content_innerhtml_fakesmilies;
  503. if (!document.getElementById("sbm_settings_content_fakesmilies"))// check if content element has already been created
  504. {
  505. // content doesn't exist - append the tab content to the target element
  506. sbOpts.childNodes[3].childNodes[3].appendChild(sbm_jsv_content_fakesmilies);
  507. }
  508. // add event listener for the save button
  509. document.getElementById('sbm_settings_save_fakesmilies').addEventListener('click',function(){
  510. var fakeSmilRows = document.getElementById("sbm_settings_content_fakesmilies").getElementsByClassName("row");
  511. var fakeSmilObj = {};
  512. for (var e in fakeSmilRows)
  513. {
  514. if (fakeSmilRows[e].firstChild)
  515. {
  516. var smilCode = fakeSmilRows[e].childNodes[0].childNodes[1].firstChild.value;
  517. var smilUrl = fakeSmilRows[e].childNodes[1].childNodes[1].firstChild.value;
  518. if (smilCode && smilUrl)
  519. {
  520. fakeSmilObj[smilCode] = smilUrl;
  521. }
  522. }
  523. }
  524. sbm_setValue("json_smilies_fake",JSON.stringify(fakeSmilObj));
  525. console.log('NGU SBMod > Fake Smilies updated - JSON: ' + sbm_getValue("json_smilies_fake"));
  526. addToSettings_Smilies();
  527. });
  528. }
  529.  
  530. function addToSettings_QuickLinks()
  531. {
  532. // get object from storage
  533. var sbm_quicklinks = JSON.parse(sbm_getValue("json_quicklinks"));
  534. // get the target element
  535. var sbOpts = document.getElementById("ngusb-options");
  536. if (!document.getElementById("sbm_settings_tab_quicklinks"))// check if tab has already been created
  537. {
  538. // create the new tab
  539. var sbm_jsv_tab_quicklinks = document.createElement("li");
  540. sbm_jsv_tab_quicklinks.id = 'sbm_settings_tab_quicklinks';
  541. sbm_jsv_tab_quicklinks.innerHTML = '<a href="#sbm_settings_content_quicklinks" data-toggle="tab">Quick Links</a>';
  542. // append the new tab to the target element
  543. sbOpts.childNodes[3].childNodes[1].appendChild(sbm_jsv_tab_quicklinks);
  544. }
  545. if (!document.getElementById("sbm_settings_content_quicklinks"))// check if content element has already been created
  546. {
  547. // content doesn't exist - create new content element
  548. var sbm_jsv_content_quicklinks = document.createElement("div");
  549. sbm_jsv_content_quicklinks.className = 'tab-pane';
  550. sbm_jsv_content_quicklinks.id = 'sbm_settings_content_quicklinks';
  551. sbm_jsv_content_quicklinks.style.maxHeight = '300px';
  552. }
  553. else
  554. {
  555. // content exists - just get the content element so it can be updated
  556. var sbm_jsv_content_quicklinks = document.getElementById("sbm_settings_content_quicklinks");
  557. }
  558. // a whole bunch of html to make / update the content
  559. var sbm_jsv_content_innerhtml_quicklinks = '<div class="form-horizontal"><b>Existing Quick Links</b> (leave any field blank to delete)<br><br>';
  560. // loop through object and add row(s) of pre-filled elements using stored data
  561. for(var z in sbm_quicklinks)
  562. {
  563. sbm_jsv_content_innerhtml_quicklinks += '<div class="row">';
  564. sbm_jsv_content_innerhtml_quicklinks += '<div class="control-group span2">';
  565. sbm_jsv_content_innerhtml_quicklinks += '<label class="control-label" style="width: 30px;">Text:</label>';
  566. sbm_jsv_content_innerhtml_quicklinks += '<div class="controls">';
  567. sbm_jsv_content_innerhtml_quicklinks += '<input type="text" size="50" name="links[text][]" value="'+z+'" style="width: 80px; margin-left: -120px;">';
  568. sbm_jsv_content_innerhtml_quicklinks += '</div>';
  569. sbm_jsv_content_innerhtml_quicklinks += '</div>';
  570. sbm_jsv_content_innerhtml_quicklinks += '<div class="control-group span2">';
  571. sbm_jsv_content_innerhtml_quicklinks += '<label class="control-label" style="width: 30px;">Url:</label>';
  572. sbm_jsv_content_innerhtml_quicklinks += '<div class="controls">';
  573. sbm_jsv_content_innerhtml_quicklinks += '<input type="text" size="50" name="links[url][]" value="'+sbm_quicklinks[z]+'" style="width: 360px; margin-left: -120px;">';
  574. sbm_jsv_content_innerhtml_quicklinks += '</div>';
  575. sbm_jsv_content_innerhtml_quicklinks += '</div>';
  576. sbm_jsv_content_innerhtml_quicklinks += '</div>';
  577. }
  578. // more html
  579. sbm_jsv_content_innerhtml_quicklinks += '<b>Add New Quick Links</b><br><br>';
  580. // add some row(s) of empty fields for additions
  581. for(var h = 0; h < 2; h++)
  582. {
  583. sbm_jsv_content_innerhtml_quicklinks += '<div class="row">';
  584. sbm_jsv_content_innerhtml_quicklinks += '<div class="control-group span2">';
  585. sbm_jsv_content_innerhtml_quicklinks += '<label class="control-label" style="width: 30px;">Text:</label>';
  586. sbm_jsv_content_innerhtml_quicklinks += '<div class="controls">';
  587. sbm_jsv_content_innerhtml_quicklinks += '<input type="text" size="50" name="links[text][]" value="" style="width: 80px; margin-left: -120px;">';
  588. sbm_jsv_content_innerhtml_quicklinks += '</div>';
  589. sbm_jsv_content_innerhtml_quicklinks += '</div>';
  590. sbm_jsv_content_innerhtml_quicklinks += '<div class="control-group span2">';
  591. sbm_jsv_content_innerhtml_quicklinks += '<label class="control-label" style="width: 30px;">Url:</label>';
  592. sbm_jsv_content_innerhtml_quicklinks += '<div class="controls">';
  593. sbm_jsv_content_innerhtml_quicklinks += '<input type="text" size="50" name="links[url][]" value="" style="width: 360px; margin-left: -120px;">';
  594. sbm_jsv_content_innerhtml_quicklinks += '</div>';
  595. sbm_jsv_content_innerhtml_quicklinks += '</div>';
  596. sbm_jsv_content_innerhtml_quicklinks += '</div>';
  597. }
  598. // end of html
  599. sbm_jsv_content_innerhtml_quicklinks += '<input value="Save Settings" type="submit" class="btn btn-primary" id="sbm_settings_save_quicklinks"></div>';
  600. // set the html of the content element
  601. sbm_jsv_content_quicklinks.innerHTML = sbm_jsv_content_innerhtml_quicklinks;
  602. if (!document.getElementById("sbm_settings_content_quicklinks"))// check if content element has already been created
  603. {
  604. // content doesn't exist - append the tab content to the target element
  605. sbOpts.childNodes[3].childNodes[3].appendChild(sbm_jsv_content_quicklinks);
  606. }
  607. // add event listener for the save button
  608. document.getElementById('sbm_settings_save_quicklinks').addEventListener('click',function(){
  609. var quickLinkRows = document.getElementById("sbm_settings_content_quicklinks").getElementsByClassName("row");
  610. var quickLinkObj = {};
  611. for (var e in quickLinkRows)
  612. {
  613. if (quickLinkRows[e].firstChild)
  614. {
  615. var linkText = quickLinkRows[e].childNodes[0].childNodes[1].firstChild.value;
  616. var linkUrl = quickLinkRows[e].childNodes[1].childNodes[1].firstChild.value;
  617. if (linkText && linkUrl)
  618. {
  619. quickLinkObj[linkText] = linkUrl;
  620. }
  621. }
  622. }
  623. sbm_setValue("json_quicklinks",JSON.stringify(quickLinkObj));
  624. console.log('NGU SBMod > Quick Links updated - JSON: ' + sbm_getValue("json_quicklinks"));
  625. addToSettings_QuickLinks();
  626. addOptionsDropdownItems();
  627. });
  628. }
  629.  
  630. //////// end of settings popup functions //////
  631. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  632. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  633. //////// context menu functions //////
  634.  
  635. function removeMenu()
  636. {
  637. // delete the context menu if it exists
  638. var contextmenu = document.getElementById("sbm_contextmenu");
  639. if (contextmenu)
  640. {
  641. contextmenu.parentNode.removeChild(contextmenu);
  642. }
  643. }
  644.  
  645. function rcMenuIgnore(uid,uname,ignore)
  646. {
  647. if (ignore)
  648. {
  649. jsShout('/ignore ' + uid);
  650. }
  651. else
  652. {
  653. jsShout('/unignore ' + uid);
  654. }
  655. }
  656.  
  657. function rightClickMenu(uid, uname, uelem)
  658. {
  659. var rcMenuUl = document.createElement("ul");
  660. rcMenuUl.className = "dropdown-menu";
  661. rcMenuUl.style.display = "none";
  662. rcMenuUl.id = "sbm_contextmenu";
  663. var rcMenuLi = document.createElement("li");
  664. rcMenuLi.innerHTML = '<a href="http://www.nextgenupdate.com/forums/member.php?u=' + uid + '" target="_blank" title="' + numberWithCommas(uid) + '">' + uelem + '</a>';
  665. rcMenuUl.appendChild(rcMenuLi);
  666. var rcMenuLi = document.createElement("li");
  667. rcMenuLi.innerHTML = '<div style="width: 100%; height: 1px; border: 0; background-color: rgba(128,128,128,0.8); margin-top: 0; margin-bottom: 0;"></div>';
  668. rcMenuUl.appendChild(rcMenuLi);
  669. var rcMenuLi = document.createElement("li");
  670. rcMenuLi.innerHTML = '<a href="#" onclick="return InfernoShoutboxControl.open_pm_tab(\'pm_'+uid+'\', \''+uname+'\');"><img class="icon" src="http://www.nextgenupdate.com/forums/images/site_icons/message.png"> Open SBPM</a>';
  671. rcMenuUl.appendChild(rcMenuLi);
  672. var rcMenuLi = document.createElement("li");
  673. rcMenuLi.innerHTML = '<a href="http://www.nextgenupdate.com/forums/search.php?do=finduser&userid='+uid+'&contenttype=vBForum_Post&showposts=1" target="_blank"><img class="icon" src="http://www.nextgenupdate.com/forums/images/site_icons/forum.png"> Find latest posts</a>';
  674. rcMenuUl.appendChild(rcMenuLi);
  675. var rcMenuLi = document.createElement("li");
  676. rcMenuLi.innerHTML = '<a href="http://www.nextgenupdate.com/forums/search.php?do=finduser&userid='+uid+'&starteronly=1&contenttype=vBForum_Thread" target="_blank"><img class="icon" src="http://www.nextgenupdate.com/forums/images/site_icons/forum.png"> Find latest started threads</a>';
  677. rcMenuUl.appendChild(rcMenuLi);
  678. var rcMenuLi = document.createElement("li");
  679. rcMenuLi.innerHTML = '<a href="http://www.nextgenupdate.com/forums/private.php?do=newpm&u=' + uid + '" target="_blank"><img class="icon" src="http://www.nextgenupdate.com/forums/images/site_icons/message.png"> Send forum PM</a>';
  680. rcMenuUl.appendChild(rcMenuLi);
  681. var rcMenuLi = document.createElement("li");
  682. var rcMenuA = document.createElement("a");
  683. rcMenuA.style.cursor = 'pointer';
  684. rcMenuA.addEventListener('click',function(){rcMenuIgnore(uid,uname,true);});
  685. rcMenuA.innerHTML = '<img class="icon" src="http://www.nextgenupdate.com/forums/images/site_icons/ignore.png"> Ignore ' + uelem;
  686. rcMenuLi.appendChild(rcMenuA);
  687. rcMenuUl.appendChild(rcMenuLi);
  688. var rcMenuLi = document.createElement("li");
  689. var rcMenuA = document.createElement("a");
  690. rcMenuA.style.cursor = 'pointer';
  691. rcMenuA.addEventListener('click',function(){rcMenuIgnore(uid,uname,false);});
  692. rcMenuA.innerHTML = '<img class="icon" src="http://www.nextgenupdate.com/forums/images/site_icons/markasread.png"> Unignore ' + uelem;
  693. rcMenuLi.appendChild(rcMenuA);
  694. rcMenuUl.appendChild(rcMenuLi);
  695.  
  696. document.getElementsByClassName('shoutbox_body')[0].appendChild(rcMenuUl);
  697. }
  698.  
  699. function contextMenuLogic(e)
  700. {
  701. e = e || window.event;
  702. var target = e.target || e.srcElement;
  703. var userElem = findUserElement(target);
  704. var userElemInner, userDetails, shoutImages;
  705. removeMenu();
  706. if (userElem)
  707. {
  708. // various conditions where context menu needs to be aborted
  709. if (userElem.getAttribute('onclick'))
  710. {
  711. if (userElem.getAttribute('onclick').indexOf("goto_pm_window") > -1)
  712. {
  713. return;
  714. }
  715. if (userElem.getAttribute('onclick').indexOf("close_tab") > -1)
  716. {
  717. return;
  718. }
  719. if (userElem.getAttribute('onclick').indexOf("open_pm_tab") > -1)
  720. {
  721. return;
  722. }
  723. }
  724. userElemInner = userElem.innerHTML;
  725. if (userElem.parentNode.parentNode.parentNode && userElem.parentNode.parentNode.parentNode.id == 'shoutbox_users_frame')
  726. {
  727. userDetails = [userIdFromHref(userElem.getAttribute('href')),target.innerHTML];
  728. }
  729. else
  730. {
  731. userDetails = userDetailsFromOnclick(userElem.getAttribute('onclick'));
  732. shoutImages = getUserPrefixImages(userElem);
  733. }
  734. if (shoutImages)
  735. {
  736. for (var i = 0; i < shoutImages.length; i++)
  737. {
  738. if (shoutImages[i])
  739. {
  740. var t = '<img ';
  741. if (shoutImages[i].style)
  742. {
  743. t = t + 'style="' + shoutImages[i].style + '" ';
  744. }
  745. t = t + 'src="' + shoutImages[i].src + '"> ';
  746. userElemInner = t + userElemInner;
  747. }
  748. }
  749. }
  750. rightClickMenu(userDetails[0], userDetails[1], userElemInner);
  751. e.preventDefault();
  752. }
  753. else
  754. {
  755. return;
  756. }
  757. // get position of click - shifted by 20px on each axis, adjust as necessary
  758. var posx = e.clientX + window.pageXOffset + 20 + 'px';
  759. var posy = e.clientY + window.pageYOffset + 20 + 'px';
  760. // set style of menu
  761. document.getElementById("sbm_contextmenu").style.position = 'absolute';
  762. document.getElementById("sbm_contextmenu").style.display = 'inline';
  763. document.getElementById("sbm_contextmenu").style.left = posx;
  764. document.getElementById("sbm_contextmenu").style.top = posy;
  765. }
  766.  
  767. //////// end of context menu functions //////
  768. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  769. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  770. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  771. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  772. //////// main script //////
  773.  
  774. // local storage checks
  775. if (sbm_getValue("bool_happyhour") === undefined)
  776. {
  777. sbm_setValue("bool_happyhour", "disabled");
  778. console.log('NGU SBMod > bool_happyhour was undefined - set to false');
  779. }
  780. if (sbm_getValue("bool_smilies_hidden") === undefined)
  781. {
  782. sbm_setValue("bool_smilies_hidden", "disabled");
  783. console.log('NGU SBMod > bool_smilies_hidden was undefined - set to false');
  784. }
  785. if (sbm_getValue("bool_smilies_elite") === undefined)
  786. {
  787. sbm_setValue("bool_smilies_elite", "disabled");
  788. console.log('NGU SBMod > bool_smilies_elite was undefined - set to false');
  789. }
  790. if (sbm_getValue("bool_smilies_weed") === undefined)
  791. {
  792. sbm_setValue("bool_smilies_weed", "disabled");
  793. console.log('NGU SBMod > bool_smilies_weed was undefined - set to false');
  794. }
  795. if (sbm_getValue("bool_smilies_fake") === undefined)
  796. {
  797. sbm_setValue("bool_smilies_fake", "disabled");
  798. console.log('NGU SBMod > bool_smilies_fake was undefined - set to false');
  799. }
  800. if (sbm_getValue("int_idletimelimit") === undefined)
  801. {
  802. sbm_setValue("int_idletimelimit",InfernoShoutboxControl.idletimelimit);
  803. console.log('NGU SBMod > int_idletimelimit was undefined - set to forum default ('+InfernoShoutboxControl.idletimelimit+')');
  804. }
  805. if (sbm_getValue("json_smilies_fake") === undefined)
  806. {
  807. sbm_setValue("json_smilies_fake",'{":housox:":"http://www.nextgenupdate.com/forums/images/smilies/housox.gif",":fap:":"http://www.nextgenupdate.com/forums/images/smilies/fap.gif"}');
  808. console.log('NGU SBMod > json_smilies_fake was undefined - example string used (2 smilies)');
  809. }
  810. if (sbm_getValue("json_quicklinks") === undefined)
  811. {
  812. sbm_setValue("json_quicklinks",'{"> Inbox":"http://www.nextgenupdate.com/forums/private.php","> Control Panel":"http://www.nextgenupdate.com/forums/usercp.php"}');
  813. console.log('NGU SBMod > json_quicklinks was undefined - example string used (2 links)');
  814. }
  815.  
  816. // context menu event listener
  817. document.addEventListener('click', function(e){contextMenuLogic(e);}, false);
  818.  
  819. // add tab(s) to settings popup
  820. addToSettings_Smilies();
  821. addToSettings_QuickLinks();
  822.  
  823. // set happy hour css on/off based on stored var
  824. if (sbm_getValue("bool_happyhour") == "enabled")
  825. {
  826. doHappyHourCSS(true);
  827. }
  828. else
  829. {
  830. doHappyHourCSS(false);
  831. }
  832.  
  833. // set idle timeout based on stored var
  834. InfernoShoutboxControl.idletimelimit = sbm_getValue("int_idletimelimit");
  835.  
  836. // add items to options dropdown menu
  837. addOptionsDropdownItems();
  838.  
  839. // sb options tweaks
  840. document.getElementById("ngusb-options").style.width = "700px";
  841. document.getElementById("ngusb-general").firstChild.style.width = "670px";
  842. document.getElementById("ngusb-general").firstChild.style.height = "300px";
  843. document.getElementById("ngusb-commands").firstChild.style.width = "670px";
  844. document.getElementById("ngusb-commands").firstChild.style.height = "300px";
  845. document.getElementById("ngusb-ignore").firstChild.style.width = "670px";
  846. document.getElementById("ngusb-ignore").firstChild.style.height = "300px";
  847. sbm_addStyle('.bootstrap .nav-tabs > li > a{padding-top: 0 !important;padding-bottom: 0 !important;padding-right: 6px !important;padding-left: 6px !important;font-size: 12px !important;}');
  848.  
  849. //////// end of main script //////
  850. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  851. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  852. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  853. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  854. //////// edited inferno functions taken from http://www.nextgenupdate.com/forums/infernoshout/browser/infernojs.js?ver=2.5.2 //////
  855.  
  856. // rewrite of the shout function to enable !commands
  857. iboxoshouts.new_shout = function()
  858. {
  859. if (iboxoshouts.posting_shout)
  860. {
  861. iboxoshouts.show_notice('A previous message is still being submitted.');
  862. return false;
  863. }
  864. if (iboxoshouts.idle)
  865. {
  866. iboxoshouts.hide_notice();
  867. }
  868. iboxoshouts.idle = false;
  869. iboxoshouts.idletime = 0;
  870. message = PHP.trim(iboxoshouts.editor.value);
  871. if (message.length > 256)
  872. {
  873. iboxoshouts.show_notice('Your shout is too long (' + message.length + ' characters), remove atleast ' + (message.length - 256) + ' characters.');
  874. return false;
  875. }
  876. if (message == '!cmd')
  877. {
  878. var cmdnotice = 'commands: [<a href="javascript:void(0);" OnClick="return InfernoShoutboxControl.hide_notice();">X</a>]<br>';
  879. cmdnotice += '!cmd - shows commands<br>';
  880. cmdnotice += '!happy - toggles happy hour<br>';
  881. cmdnotice += '!idle,(int) - set idle timeout in seconds - use !idle,-1 to disable<br>';
  882. cmdnotice += '!goidle - go idle right away<br>';
  883. cmdnotice += '!spam|(number of messages)|message - will get you banned';
  884. InfernoShoutboxControl.show_notice(cmdnotice);
  885. clearTimeout(InfernoShoutboxControl.kill_notice);
  886. iboxoshouts.editor.value = '';
  887. return false;
  888. }
  889. else if (message.substring(0, 5) == '!idle')
  890. {
  891. iboxoshouts.editor.value = '';
  892. var idleCmd = message.split(",",2);
  893. if (isNaN(idleCmd[1]))
  894. {
  895. iboxoshouts.show_notice(idleCmd[1]+' is not a number. Try !idle,-1');
  896. }
  897. else
  898. {
  899. setIdletime(idleCmd[1]);
  900. }
  901. return false;
  902. }
  903. else if (message == '!goidle')
  904. {
  905. iboxoshouts.editor.value = '';
  906. iboxoshouts.idle = true;
  907. return false;
  908. }
  909. else if (message.substring(0, 5) == '!spam')
  910. {
  911. iboxoshouts.editor.value = '';
  912. var spamCmd = message.split("|",3);
  913. if (isNaN(spamCmd[1]))
  914. {
  915. iboxoshouts.show_notice(spamCmd[1]+' is not a number!');
  916. }
  917. else
  918. {
  919. var sbSpamTime = (iboxoshouts.floodtime * 1000) + 1000;
  920. var number2 = 0;
  921. iboxoshouts.show_notice('Spamming "'+spamCmd[2]+'" <b class="highlight">'+spamCmd[1]+'</b> times, <a style="cursor: pointer;" onclick="return killSpam(\'spam cancelled\');">click here</a> to cancel...');
  922. spam = true;
  923. leSBSpam = setInterval(function ()
  924. {
  925. number2++;
  926. if (number2 > spamCmd[1])
  927. {
  928. return false;
  929. }
  930. jsShout(spamCmd[2]);
  931. shoutsleft = spamCmd[1] - number2;
  932. if (shoutsleft > 0)
  933. {
  934. iboxoshouts.show_notice('<b class="highlight">'+shoutsleft+'</b> shouts left to spam, <a style="cursor: pointer;" onclick="return killSpam(\'spam cancelled\');">click here</a> to cancel...');
  935. }
  936. else
  937. {
  938. iboxoshouts.show_notice('Spam finished');
  939. }
  940. }, sbSpamTime);
  941. }
  942. return false;
  943. }
  944. else if (message == '!happy')
  945. {
  946. toggleDropdownElement("bool_happyhour","sbm_dropdown_happyhour","Happy Hour");
  947. if (sbm_getValue("bool_happyhour") == "enabled")
  948. {
  949. doHappyHourCSS(true);
  950. }
  951. else
  952. {
  953. doHappyHourCSS(false);
  954. }
  955. iboxoshouts.editor.value = '';
  956. return false;
  957. }
  958. else
  959. {
  960. if (message === '')
  961. {
  962. iboxoshouts.show_notice('Please enter a message first.');
  963. return false;
  964. }
  965. }
  966. message = iboxoshouts.shout_params.prefix + message + iboxoshouts.shout_params.suffix;
  967. iboxoshouts.posting_shout = true;
  968. iboxoshouts.set_loader('');
  969. iboxoshouts.shout.ajax = new vB_AJAX_Handler(true);
  970. iboxoshouts.shout.ajax.onreadystatechange(InfernoShoutboxControl.shout_posted);
  971. iboxoshouts.shout.ajax.send('infernoshout.php', 'do=shout&message=' + PHP.urlencode(message));
  972. iboxoshouts.clear();
  973. return false;
  974. };
  975. iboxoshouts.shout = iboxoshouts.new_shout;
  976.  
  977. // rewrite of update_shouts to add things
  978. iboxoshouts.new_update_shouts = function(shouts)
  979. {
  980. iboxoshouts.shoutframe.innerHTML = '';
  981. if (sbm_getValue("bool_smilies_fake") == "enabled")
  982. {
  983. var sSmil = JSON.parse(sbm_getValue("json_smilies_fake"));
  984. for(var k in sSmil)
  985. {
  986. var re = new RegExp(k,"g");
  987. shouts = shouts.replace(re, '<a href="'+sSmil[k]+'" target="_blank" title="'+[k]+'"><img src="'+sSmil[k]+'"></a>');
  988. }
  989. }
  990. var sbpmInline = new RegExp("InfernoShoutboxControl.open_pm_tab","g");
  991. shouts = shouts.replace(sbpmInline, "sbmodDropdownMenu");
  992. iboxoshouts.shoutframe.innerHTML = shouts;
  993. if (iboxoshouts.newestbottom && iboxoshouts.shoutframe.scrollTop < iboxoshouts.shoutframe.scrollHeight)
  994. {
  995. iboxoshouts.shoutframe.scrollTop = iboxoshouts.shoutframe.scrollHeight;
  996. }
  997. if (spam)
  998. {
  999. var trigger = '\u00D7';
  1000. if (shouts.indexOf(trigger) > -1)
  1001. {
  1002. killSpam('SHOOP DA WOOP');
  1003. }
  1004. }
  1005. };
  1006. iboxoshouts.update_shouts = iboxoshouts.new_update_shouts;
  1007.  
  1008. // rewrite of smilies_fetched to add smilies to the menu
  1009. iboxoshouts.new_smilies_fetched = function()
  1010. {
  1011. ajax = InfernoShoutboxControl.fetchsmilies.ajax;
  1012. if (ajax.handler.readyState == 4 && ajax.handler.status == 200)
  1013. {
  1014. InfernoShoutboxControl.set_loader('none');
  1015. InfernoShoutboxControl.fetchingsmilies = false;
  1016. InfernoShoutboxControl.smiliesbox.style.display = '';
  1017. InfernoShoutboxControl.smiliesrow.innerHTML = ajax.handler.responseText;
  1018. if (sbm_getValue("bool_smilies_hidden") == "enabled")
  1019. {
  1020. for(var k in sbm_smilies_hidden)
  1021. {
  1022. var HTML = '<span style="padding-right: 2px; padding-left: 2px">';
  1023. HTML += '<img ';
  1024. HTML += 'src="'+sbm_smilies_hidden[k]+'" ';
  1025. HTML += 'title="'+k+'" ';
  1026. HTML += 'onclick="InfernoShoutboxControl.append_smilie(\''+k+'\');" ';
  1027. HTML += 'onmouseover="this.style.cursor = \'pointer\';" ';
  1028. HTML += 'style="cursor: pointer; max-height: 40px">';
  1029. HTML += '</span>';
  1030. InfernoShoutboxControl.smiliesrow.innerHTML += HTML;
  1031. }
  1032. }
  1033. if (sbm_getValue("bool_smilies_elite") == "enabled")
  1034. {
  1035. for(var k in sbm_smilies_elite)
  1036. {
  1037. var HTML = '<span style="padding-right: 2px; padding-left: 2px">';
  1038. HTML += '<img ';
  1039. HTML += 'src="'+sbm_smilies_elite[k]+'" ';
  1040. HTML += 'title="'+k+'" ';
  1041. HTML += 'onclick="InfernoShoutboxControl.append_smilie(\''+k+'\');" ';
  1042. HTML += 'onmouseover="this.style.cursor = \'pointer\';" ';
  1043. HTML += 'style="cursor: pointer; max-height: 40px">';
  1044. HTML += '</span>';
  1045. InfernoShoutboxControl.smiliesrow.innerHTML += HTML;
  1046. }
  1047. }
  1048. if (sbm_getValue("bool_smilies_weed") == "enabled")
  1049. {
  1050. for(var k in sbm_smilies_weed)
  1051. {
  1052. var HTML = '<span style="padding-right: 2px; padding-left: 2px">';
  1053. HTML += '<img ';
  1054. HTML += 'src="'+sbm_smilies_weed[k]+'" ';
  1055. HTML += 'title="'+k+'" ';
  1056. HTML += 'onclick="InfernoShoutboxControl.append_smilie(\''+k+'\');" ';
  1057. HTML += 'onmouseover="this.style.cursor = \'pointer\';" ';
  1058. HTML += 'style="cursor: pointer; max-height: 40px">';
  1059. HTML += '</span>';
  1060. InfernoShoutboxControl.smiliesrow.innerHTML += HTML;
  1061. }
  1062. }
  1063. if (sbm_getValue("bool_smilies_fake") == "enabled")
  1064. {
  1065. var mSmil = JSON.parse(sbm_getValue("json_smilies_fake"));
  1066. for(var k in mSmil)
  1067. {
  1068. var fHTML = '<span style="padding-right: 2px; padding-left: 2px">';
  1069. fHTML += '<img ';
  1070. fHTML += 'src="'+mSmil[k]+'" ';
  1071. fHTML += 'title="'+k+'" ';
  1072. fHTML += 'onclick="InfernoShoutboxControl.append_smilie(\''+k+'\');" ';
  1073. fHTML += 'onmouseover="this.style.cursor = \'pointer\';" ';
  1074. fHTML += 'style="cursor: pointer; max-height: 40px">';
  1075. fHTML += '</span>';
  1076. InfernoShoutboxControl.smiliesrow.innerHTML += fHTML;
  1077. }
  1078. }
  1079. }
  1080. };
  1081.  
  1082. iboxoshouts.smilies_fetched = iboxoshouts.new_smilies_fetched;
  1083.  
  1084. //////// end of edited inferno functions //////
  1085. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////