Jump to content

User:Polygnotus/Scripts/ExtraButtons.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
//I should be able to combine these
//colours are weird in dark mode

// <nowiki>
if (['edit', 'submit'].indexOf(mw.config.get('wgAction')) !== -1) {
  mw.hook('wikiEditor.toolbarReady').add(function($textarea) {
    
    $textarea.wikiEditor('addToToolbar', {
      section: 'advanced',
      group: 'insert',
      tools: {
        welcomeButton: {
          label: 'Welcome',
          filters: [ 'body.ns-3' ],
          type: 'button',
          icon: '//upload.wikimedia.org/wikipedia/commons/6/6f/Handshake_icon_BLACK_and_WHITE.svg',
          action: {
            type: 'encapsulate',
            options: {
              pre: '{{subst:' + 'User:Polygnotus/Templates/welcome}} ~~' + '~~',
            }
          }
        },
        teahouseButton: {
          label: 'Teahouse',
          filters: [ 'body.ns-3' ],
          type: 'button',
          icon: '//upload.wikimedia.org/wikipedia/commons/0/0d/Questionmark_SVG_4.svg',
          action: {
            type: 'encapsulate',
            options: {
              pre: 'If you have any questions, the [[WP:TEAHOUSE]] is a great place to get answers.',
            }
          }
        },
        vand1Button: {
          label: 'Vandalism warning level 1',
          filters: [ 'body.ns-3' ],
          type: 'button',
          icon: '//upload.wikimedia.org/wikipedia/commons/8/8a/Eo_circle_grey_number-1.svg',
          action: {
            type: 'encapsulate',
            options: {
              pre: '{{subst:' + 'uw-vand1}} ~~' + '~~',
            }
          }
        },
        vand2Button: {
          label: 'Vandalism warning level 2',
          filters: [ 'body.ns-3' ],
          type: 'button',
          icon: '//upload.wikimedia.org/wikipedia/commons/c/c7/Eo_circle_yellow_number-2.svg',
          action: {
            type: 'encapsulate',
            options: {
              pre: '{{subst:' + 'uw-vand2}} ~~' + '~~',
            }
          }
        },
        vand3Button: {
          label: 'Vandalism warning level 3',
          filters: [ 'body.ns-3' ],
          type: 'button',
          icon: '//upload.wikimedia.org/wikipedia/commons/c/c5/Eo_circle_deep-orange_number-3.svg',
          action: {
            type: 'encapsulate',
            options: {
              pre: '{{subst:' + 'uw-vand3}} ~~' + '~~',
            }
          }
        },
        vand4Button: {
          label: 'Vandalism warning level 4',
          filters: [ 'body.ns-3' ],
          type: 'button',
          icon: '//upload.wikimedia.org/wikipedia/commons/c/cd/Eo_circle_red_number-4.svg',
          action: {
            type: 'encapsulate',
            options: {
              pre: '{{subst:' + 'uw-vand4}} ~~' + '~~',
            }
          }
        }
      }
    });

  });
}

// </nowiki>