User:JustLeafy/global.js

//__NOWYSIWYG__ \ \ table.wikiacontribs {\ border: 2px solid #a5a4a3;\ width: 100%;\ }\ table.wikiacontribs th {\ background: #dcdbd8;\ text-align: -webkit-center;\ display: table-cell;\ width: auto;\ padding: 26px;\ }\ section#wikiacontribs {\ width: 175% !important;   left: 12% !important;\ }\ @media screen and (min-width: 700px ) {\ section#wikiacontribs {\ width: 74% !important;   left: 5% !important;\ }\ }\ .spindashspinlikeyourlifedependsonit::after {\ background: url(https://slot1-images.wikia.nocookie.net/__cb1510749070/common/skins/common/images/ajax.gif);\ content: \' \';\ width: 16px;\ height: 17px;\ position: absolute;\ zoom: 3;\ }\ table.wikiacontribs td {\ padding: 17px;\ border-bottom: 2px solid #dbdad8;\ }\ section.modalWrapper#wikiacontribs {\ position: absolute;\ top: 20px !important;\ left: 12% !important;\ margin: 0 !important;\ }\ section#wikiacontribs .modalContent {\ height: calc(50pc) !important;\ overflow: scroll;\ }\ section#wikiacontribs h1 {\ font-family: fantasy;\ font-size: 40px;\ text-align: center;\ }\ ', {                   id: "wikiacontribs", callback: function { $('.searchlog').on('keydown', function(key) {                           if (key.keyCode === 13) {                                checkUserStats(key.target.value, 0);                            } else {                                $.get("/api.php?action=query&list=allusers&aufrom=" + key.target.value + "&format=json", function(response) { $('#searchloglist option').remove; response.query.allusers.forEach(function(d, v) {                                       $('#searchloglist').append('' + d.name + " ");                                    }) });                           }                        })                        $('#cleanlist').on('click', function {                            $('.wikiacontribs tr:not(.headers)').remove                        }) function checkUserStats(d, v) { document.getElementsByClassName("headerstats")[0].classList.add("spindashspinlikeyourlifedependsonit"); $.get("/api.php", {                               action: "query",                                list: "users",                                ususers: d,                                usprop: "groups|editcount|gender|registration",                                format: "json"                            }, function(second) {                                if (second.query.users === [] || second.error || !second.query.users[0] ) {                                    console.log(d);                                    return $('table.wikiacontribs').append(" " + d + " does not exist.  ");                                }                                var cells = ' ';                                $.ajax({ url: "/api.php", data: { action: "query", list: "usercontribs", ucuser: d,                                       format: "json" },                                   method: "GET", format: "JSON", }).always(function(third) { $.get("https://services.wikia.com/user-attribute/user/" + second.query.users[0].userid, function(forth) {                                       cells += " " + second.query.users[0].userid + " ";                                        if (forth._embedded && forth._embedded.properties) {                                            forth._embedded.properties.forEach(function(b) { if (b.name == "avatar") { return cells += "  "; }                                           })                                        }                                        if (!cells.match(/ ";                                        }                                        cells += "" + second.query.users[0].name + " (talk) • (profile) ";                                        cells += " " + second.query.users[0].gender + " ";                                        cells += " " + second.query.users[0].groups.join(", ") + " "; cells += " " + second.query.users[0].editcount + " "; if (third.query && third.query.usercontribs[0]) { var date = new Date(third.query.usercontribs[0].timestamp); var interval = Date.parse(new Date) - date; var seconds = Math.floor((interval / 1000) % 60); var minutes = Math.floor((interval / 1000 / 60) % 60); var hours = Math.floor((interval / (1000 * 60 * 60)) % 24); var days = Math.floor(interval / (1000 * 60 * 60 * 24)); cells += "" + (date.getMonth + 1) + "/" + date.getDate.toString + "/" + (date.getFullYear) + " "; } else { cells += " null "; }                                       var date = new Date(second.query.users[0].registration); cells += " " + (date.getMonth + 1) + "/" + date.getDate.toString + "/" + (date.getFullYear) + " "; cells += " "; return $('table.wikiacontribs').append(cells); });                                   setTimeout(function { document.getElementsByClassName("headerstats")[0].classList.remove("spindashspinlikeyourlifedependsonit"); }, 5000)                               })                            })                        }                        $('#wikiacontribs #initiate').on('click', function { var offsetgm = 0; function gmAPI(offsetgm) { $.ajax({                                   url: "/api.php",                                    data: {                                        action: "query",                                        list: "groupmembers",                                        gmgroups: $('input.gmrights').val === "" ? 'bureaucrat|sysop' : $('input.gmrights').val,                                        gmlimit: 500,                                        gmoffeset: offsetgm,                                        format: "json"                                    },                                    method: "GET",                                    format: "JSON",                                }).always(function(response) {                                    if (response.user == []) {                                        return $('.wikiacontribs').append("No users found "); }                                   response.users.forEach(function(d, v) {                                        checkUserStats(d.name, v);                                        if (response.users.length == v && response["query-continue"]) {                                            gmAPI(response["query-continue"].groupmembers.gmoffeset);                                        }                                    }) });                           }                            gmAPI(offsetgm);                        }); $('button.wikia-button.gmusercheck').on('click', function {                           $.showCustomModal('', '  #userrightsbatch{width:auto !important;height:auto !important} ', { id: "userrightsbatch", buttons: [{ id: "startuserbatchscript", message: "Start Batch" }],                               callback: function { $('#startuserbatchscript').on('click', function {                                       $('textarea#userrightsbatch').val.match(/^(.*?)$/gmi).forEach(function(v, d) { checkUserStats(v, d); });                                       $('#userrightsbatch .close').click;                                    }); }                           })                        })                    }                });            });            return tru.condition = "true"; }   }, 2000) }(window, mw, $)); //

//Random Page Shortcut $(function {   var newpage = $('.wds-community-header__wiki-buttons a[data-tracking="wiki-activity"]');    newpage.clone.attr({href: '/wiki/Special:Random', title: 'Random Page', 'data-tracking': 'random-page'}).insertAfter(newpage)        .find('svg').attr('id', '').html(' '); });

$(function {   if(actions) {            importArticle({type: 'style', article: 'u:justleafy:MediaWiki:ModernLightbox/code.css'});    }    var $galleries, $pi, cache;    if (window.wgEnableMediaGalleryExt) {        $galleries = $('div.media-gallery-wrapper');    } else {        $galleries = $('div.wikia-gallery');    }//if new gallery    $pi = $('.portable-infobox');    if (!$galleries.length && !$pi.length) return;    $(window).on('lightboxOpened', function { //gather captions across galleries and infoboxes if (!cache) { cache = []; //gallery if (window.wgEnableMediaGalleryExt) { $galleries.each(function(i, v) {                   var data = $(v).data('model');                    if (!data) return;                    $.each(data, function(i, v) { //recode key. just for fun and consistency, cuz this key encoded fine already var imgname = encodeURIComponent(decodeURIComponent(v.dbKey)); v.captionText = (v.caption || ).replace(/(<([^>]+)>)/ig, ); cache[imgname] = v;                   });//each data-model                });//each gallery } else { $galleries.find('.wikia-gallery-item .thumbimage').each(function(i, v) {                   var caption = $(v).closest('.wikia-gallery-item').find('.lightbox-caption');                    //recode key, cuz it encoded by weird way                    cache[encodeURIComponent(decodeURIComponent(v.dataset.imageKey))] = {                        caption: caption.html,                        captionText: (caption.text || ).replace(/(<([^>]+)>)/ig, )                    };                });//each gallery }//if new gallery //infobox $pi.each(function(i, v) {               $(v).find('.pi-image').each(function(i, v) { var $piImage = $(v); var caption = $piImage.find('.pi-caption'); cache[encodeURIComponent(decodeURIComponent($piImage.find('img').data('imageKey')))] = { caption: caption.html, captionText: (caption.text || ).replace(/(<([^>]+)>)/ig, ) };               });//each image            });//each pi        }//if !cache //w8. not loaded yet setTimeout(function {           //timeout, do not create multiple timers in case of fast closed lightbox            var $lb = $('#LightboxModal');            var thumbs = ((window.Lightbox || {}).current || {}).thumbs;            if (!$lb.length || !thumbs || !thumbs.length) return;            var $caption = $(' ', { class: 'gc-caption' });           function onClick (e) {                var thumb = thumbs[window.Lightbox.current.index];                $caption.html(thumb.gcCaption || thumb.title || '');            }//onclick            $lb.find('.content .toolbar').append($('<li>').append($caption));            $.each(thumbs, function(i, v) { if (!v.key) return false; //recode key, cuz it encoded by weird way var item = cache[encodeURIComponent(decodeURIComponent(v.key))]; if (!item) return; v.gcCaption = item.caption; v.gcCaptionText = item.captionText; });//each thumb           $lb.on('click.gc', '#LightboxCarouselContainer .carousel li', onClick);            //show caption to starter item            onClick;            //add title            $lb.find('#LightboxCarouselContainer .carousel li').each(function(i, v) { var $v = $(v); if($v.hasClass('more-items')) { return false; } else { var $img = $v.find('img'); $img.attr('title', thumbs[i].gcCaptionText); }//if });//each li       }, 1000);//timeout });//lightboxOpened });