MediaWiki:Common.js

From Redbrick Wiki
Revision as of 22:21, 21 April 2026 by Graggle (talk | contribs)
Jump to navigation Jump to search

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)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
mw.hook('wikipage.content').add(function () {
    var cats = mw.config.get('wgCategories');
    if (!cats || cats.indexOf('Archive') === -1) return;

    // Call the MediaWiki API to parse the template
    $.ajax({
        url: mw.util.wikiScript('api'),
        data: {
            action: 'parse',
            text: '{{Archived}}',
            contentmodel: 'wikitext',
            format: 'json'
        },
        dataType: 'json',
        success: function (data) {
            if (data.parse && data.parse.text) {
                var html = data.parse.text['*'];
                $('.mw-parser-output').prepend(html);
                $('.mw-parser-output').prepend('\n');
            }
        }
    });
});