Misplaced Pages

User:GoldenRing/userlinks.js: Difference between revisions

Article snapshot taken from Wikipedia with creative commons attribution-sharealike license. Give it a read and then ask your questions in the chat. We can research this topic together.
< User:GoldenRing Browse history interactively← Previous editContent deleted Content added
Revision as of 16:12, 16 November 2017 view sourceGoldenRing (talk | contribs)Extended confirmed users6,924 edits fix defects← Previous edit Latest revision as of 16:03, 26 September 2020 view source MusikAnimal (talk | contribs)Edit filter managers, Autopatrolled, Interface administrators, Administrators120,542 edits rm {{pp-template}} as page is not template-protected; user CSS/JS is automatically protected so only yourself or interface admins can edit it, anyway 
Line 1: Line 1:
// {{pp-template}} <pre> <nowiki> // <pre> <nowiki>


(function() { (function() {

Latest revision as of 16:03, 26 September 2020

// <pre> <nowiki>

(function() {
    $(document).ready(function() {
	var div = $("<div></div>");
        div.css({
            display: 'none',
            border: 'solid thin black',
            position: 'absolute',
            'background-color': '#ffffff',
            'z-index': '10',
            padding: '0.3em'
        });
        div.attr('id', 'gr-userlinks-hover');
        $('body').append(div);
        var hidetimer = null;
        var hidebox = function() {
            $('#gr-userlinks-hover').css('display', 'none');
            hidetimer = null;
        }            
        var wikilink = function(l, t) {
            return '<a href="' + mw.config.get('wgServer') + '/' + l + '">' + t + '</a>';
        }
        $("a.userlink, a.mw-userlink").hover(
            function() {
                if (hidetimer != null) {
                    window.clearTimeout(hidetimer);
                }
                var title = $(this).attr('title');
                var username = title.split(':');
                var dne = ' (page does not exist)';
                if( username.endsWith(dne) )
                    username = username.substring(0, username.indexOf(dne));
                if( username.indexOf(";") > 0 )
                    username = username.substring(0, username.indexOf(";"));
                console.log(username);
                $('#gr-userlinks-hover')
                    .html(wikilink('User talk:' + username, 'talk') + ' ' + wikilink('Special:Contributions/' + username, 'contribs') + ' <a href="https://xtools.wmflabs.org/ec/en.wikipedia.org/' + username + '">X!</a> ' + wikilink('Special:Log/' + username, 'log') + ' ' + wikilink('Special:Log/block?page=' + username, 'block log') + ' ' + wikilink('Special:DeletedContributions/' + username, 'deleted contribs'))
                    .css({
                        display: 'block',
                        top: $(this).offset().top + $(this).height() + 3,
                        left: $(this).offset().left
                    });
            },
            function() {
                hidetimer = window.setTimeout(hidebox, 250);
            }
        ); 
        $("#gr-userlinks-hover").hover(
            function() {
                if (hidetimer != null) window.clearTimeout(hidetimer);
            },
            function() {
                hidetimer = window.setTimeout(hidebox, 250);
            }
        );
    });
} ());
// </nowiki> </pre>