Advertisement
thetenfold

TheCelebrityCity - Add Reply Buttons v1.0.4

Nov 15th, 2013
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name        TheCelebrityCity - Add Reply Buttons
  3. // @namespace   http://userscripts.org/users/23652
  4. // @description Adds some reply buttons, like IMG
  5. // @include     http://*.thecelebritycity.com/forum/viewtopic.php*t=*
  6. // @copyright   JoeSimmons
  7. // @version     1.0.4
  8. // @license     http://creativecommons.org/licenses/by-nc-nd/3.0/us/
  9. // @require     https://raw.github.com/joesimmons/jsl/master/jsl.user.js
  10. // @grant       GM_addStyle
  11. // ==/UserScript==
  12.  
  13. +function () {
  14.  
  15.  
  16.  
  17.     var buttons = {
  18.  
  19.  
  20.     // -------- INSERT BUTTONS HERE --------
  21.         '[img]'          : [ '[img]' , '[/img]' ],
  22.         'text [img]'     : [ 'text [img]' , '[/img]' ],
  23.         'text only'      : [ 'text only' , '' ],
  24.     // -------------------------------------
  25.  
  26.  
  27.     '_b' : ''};
  28.  
  29.  
  30.  
  31.     // Make sure the page is not in a frame
  32.     if (window.self !== window.top) { return; }
  33.  
  34.     JSL.runAt('end', function () {
  35.         var holder = JSL('#qr_editor_div .inner fieldset dl dd'),
  36.             autopost = true, autoprompt = true, button;
  37.  
  38.         JSL.addStyle('' +
  39.             '.b1 { ' +
  40.                 'margin: 0 10px;' +
  41.             '}' +
  42.         '');
  43.  
  44.         if (holder.exists) {
  45.             holder.append(
  46.                 JSL.create('label', {'class' : 'b1', textContent : 'Auto-post? '}, [
  47.                     JSL.create('input', {type : 'checkbox', id : 'b1autopost'})
  48.                 ])
  49.             );
  50.             holder.append(
  51.                 JSL.create('label', {'class' : 'b1', textContent : 'Prompt? '}, [
  52.                     JSL.create('input', {type : 'checkbox', id : 'b1autoprompt'})
  53.                 ])
  54.             );
  55.             JSL('#b1autopost')
  56.                 .prop('checked', true)
  57.                 .addEvent('change', function () {
  58.                     autopost = this.checked;
  59.                 });
  60.             JSL('#b1autoprompt')
  61.                 .prop('checked', true)
  62.                 .addEvent('change', function () {
  63.                     autoprompt = this.checked;
  64.                 });
  65.  
  66.             for (button in buttons) {
  67.                 if ( button !== '_b' && buttons.hasOwnProperty(button) ) {
  68.                     holder.append(
  69.                         JSL.create('input', {type : 'button', 'class' : 'button1 b1', value : button, onclick : function (event) {
  70.                             var box = JSL('#message-box textarea[name="message"]')[0],
  71.                                 name = this.value,
  72.                                 val = buttons[name],
  73.                                 pr = autoprompt === true ? prompt('URL Link') : '';
  74.  
  75.                             event.preventDefault();
  76.  
  77.                             if (typeof pr === 'string') {
  78.                                 box.value += val[0] + pr + val[1];
  79.                                 box.focus();
  80.  
  81.                                 if (autopost === true && name !== '[img]') {
  82.                                     JSL('#qr_editor_div input[type="submit"][name="post"]')[0].click();
  83.                                 }
  84.                             }
  85.                         }})
  86.                     );
  87.                 }
  88.             }
  89.         }
  90.     });
  91.  
  92. }();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement