User:Polygnotus/Scripts/WikiEditorToolbar.js

This is an old revision of this page, as edited by Polygnotus (talk | contribs) at 03:08, 25 June 2024. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
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

if (['edit', 'submit'].indexOf(mw.config.get('wgAction')) !== -1) {
  mw.hook('wikiEditor.toolbarReady').add(function($textarea) {
    
    $textarea.wikiEditor('addToToolbar', {
      section: 'advanced',
      group: 'insert',
      label: 'foobar',
      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:' + 'Welcome-newuser|heading=no}} ~~' + '~~',
            }
          }
        },
        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}} ~~' + '~~',
            }
          }
        }
      }
    });

  });
}