SHARE
TWEET

Untitled

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