Fandom Developers Wiki
Advertisement

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.
/**
 * Name:        WhatLinksHere
 * Version:     v1.1
 * Author:      KockaAdmiralac <wikia@kocka.tech>
 * 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'
    });
})();
Advertisement