Jump to content

MediaWiki:Common.js

From The Rubric
Revision as of 22:44, 18 August 2026 by The Dented Pen (talk | contribs) (Added copy button javascript)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
/* Any JavaScript here will be loaded for all users on every page load. */
mw.hook('wikipage.content').add(function($content) {
    $content.find('.wiki-copy-btn').on('click', function() {
        var textToCopy = $(this).attr('data-text');
        navigator.clipboard.writeText(textToCopy).then(function() {
            alert('Copied to clipboard!');
        });
    });
});