×
Create a new article
Write your page title here:
We currently have 179 articles on NBITTRPG Wiki. Type your article name above or click on one of the titles below and start writing!



NBITTRPG Wiki
Revision as of 12:08, 4 March 2025 by CStatic (talk | contribs) (Created page with "Any JavaScript here will be loaded for all users on every page load.: * * Name: WhatLinksHere * Version: v1.1 * Author: KockaAdmiralac <[email protected]> * Description: Adds a link to Special:WhatLinksHere below the edit dropdown: (function() { 'use strict'; var $list = $('.page-header__contribution-buttons .wds-list, .page-header__actions .wds-list, .UserProfileActionButton .WikiaMenuElement'); if (!$list.length || window.Wha...")
(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. */
/**
 * Name:        WhatLinksHere
 * Version:     v1.1
 * Author:      KockaAdmiralac <[email protected]>
 * Description: Adds a link to Special:WhatLinksHere below the edit dropdown
 */

(function() {
    'use strict';

    var $list = $('.page-header__contribution-buttons .wds-list, .page-header__actions .wds-list, .UserProfileActionButton .WikiaMenuElement');

    if (!$list.length || window.WhatLinksHereLoaded) {
        return;
    }
    window.WhatLinksHereLoaded = true;

    var config = mw.config.get([
        'wgPageName',
        'wgUserLanguage'
    ]);

    mw.hook('dev.fetch').add(function(fetch) {
        $.when(
            fetch('whatlinkshere'),
            mw.loader.using('mediawiki.util')
        ).then(function(text) {
            var url = mw.util.getUrl('Special:WhatLinksHere/' + config.wgPageName);
            $list.append(
                $('<li>', {
                    id: 'ca-whatlinkshere'
                }).append(
                    $('<a>', {
                        href: url,
                        text: text
                    })
                )
            );
            if (mw.util.getParamValue('redirect') === 'no') {
                $('.redirectText').append(
                    $('<br>'),
                    $('<span>', {
                        id: 'redirectWLH'
                    }).append(
                        '→ ',
                        $('<a>', {
                            'class': 'redirectWLH-link',
                            href: url,
                            text: text
                        })
                    )
                );
            }
        });
    });
    importArticle({
        type: 'script',
        article: 'u:dev:MediaWiki:Fetch.js'
    });
})();