User:Sophiedp/global.js

//////////////////////////////////////////////////////////////////////////////// //———————————————————————————————————————————————————————————————————————————— // Direct JavaScript code. /* Direct Javascript code is here either because a page does not exist for it  here on Wikia's and Wikimedia's domain or if I want to customize it. It is  large and slow, but completely customizable. When there is a code/etc.js page with the code, please put the page name into ImportArticles at the bottom of  this page instead. */ //———————————————————————————————————————————————————————————————————————————— ////////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////// /**/ ///————————————————————— Direct JavaScript code ———————————————————————/// /**/ ////////////////////////////////////////////////////////////////////////////////

/* Make RecentChanges show bot edits by changing the url */ //@author-Foodbandlt if (wgPageName == "Special:RecentChanges") { //only run on RecentChanges if (window.location.href.indexOf("hidebots=") == -1 && window.location.href.indexOf("?") == -1) { //if the url doesn't have ?hidebots=0 window.location.href = window.location.href + "?hidebots=0"; //add ?hidebots=0 } else if (window.location.href.indexOf("hidebots=") == -1 && window.location.href.indexOf("?") !== -1) { //if the url doesn't have hidebots in it and there is a ? in the url window.location.href = window.location.href + "&hidebots=0"; //add &hidebots=0 } }

/* Remove the part of the url that opens the editor on redlinks */ var head = $('a[href$="?action=edit&redlink=1"]'); if (head.attr("href")) { //if ?action=edit&redlink=1 is in the url head.attr("href", head.attr("href").replace("?action=edit&redlink=1", "")); //remove it }

/* Highlight whitespace characters in diffs when they're the only thing that was changed */ if (window.location.href.indexOf("diff=") !== -1) { //if on a diff page $(".diffchange-inline").each(function {        if (!(new RegExp("\\S+")).test($(this).text)) { //if whitespace            $(this).css("background-color", "red"); //make it red        }    }); }

/* Add links to global.js and global.css to global nav */ //@author-Kocka window.globalLinks = { global: { //       "CSS"  : "User:Sophiedp/global.css", disabled because their is noting on the page "JS"  : "User:Sophiedp/global.js" } }; $(function {   var linksContent = "",        wiki = window.location.host.split("."),        page = mw.config.get('wgPageName'),        user = mw.config.get('wgUserName'),        links = window.globalLinks || {};    wiki = wiki.slice(0, wiki.length - 2).join("."),    links = $.extend(links.global, links[wiki]);    for(var prop in links) {        if(links.hasOwnProperty(prop)) {            var link = links[prop]                .replace(/%page%/g, page)                .replace(/%user%/g, user);            linksContent += mw.html.element("a", { class: "wds-global-navigation__link global-nav-link", href: "http://central.wikia.com/wiki/" + link, target: "_self" }, prop);       }    }    $(".notifications-container").after(linksContent); });

/* Code to create my userpage or message wall greeting by clicking on a link */ if (wgCityId !== "621556") { //don't run on suwiki /* Create my userpage */ //Modified version of QuickCreateUserPage $('', {       id: 'qcup',    }).html('Create user page') //create the link .prependTo('.toolbar .tools') //put it in the toolbar .click(function { //when clicked       $.ajax( { //create the userpage type: 'POST', url: mw.util.wikiScript( 'api' ), dataType: 'json', data: { action: 'edit', title: 'User:Sophiedp', //at this page summary: 'Creating user page (script)', //with this edit summary text: '', //using this tempalte format: 'json', token: mw.user.tokens.get( 'editToken' ) }       } ).done( function ( data ) { if ( data.edit.result === 'Success' ) { new BannerNotification("Successfully created page!","confirm").show; //say we created the page } else { new BannerNotification("An error occurred.","error").show; //say we didn't create the page }       } ).fail( function ( data ) { new BannerNotification("An error occurred.","error").show; //say we didn't create the page } );   });    /* Create my messaage wall greeting */ //Modified version of QuickCreateMessageWallGreeting $('', {       id: 'qcmwg',    }).html('Create Greeting') //create the link .prependTo('#my-tools-menu') //put it in the my tools menu on the toolbar .click(function { //when clicked       $.ajax( { //create the message wall greeting type: 'POST', url: mw.util.wikiScript( 'api' ), dataType: 'json', data: { action: 'edit', title: 'Message_Wall_Greeting:Sophiedp', //at this page summary: 'Creating message wall greeting (script)', //with this edit summary text: '', //using this template format: 'json', token: mw.user.tokens.get( 'editToken' ) }       } ).done( function ( data ) { if ( data.edit.result === 'Success' ) { new BannerNotification("Successfully created page!","confirm").show; //say we created the page } else { new BannerNotification("An error occurred.","error").show; //say we didn't create the page }       } ).fail( function ( data ) { new BannerNotification("An error occurred.","error").show; //say we didn't create the page } );   }); }

//////////////////////////////////////////////////////////////////////////////// //// // ——————————————————— End Direct Import JavaScript Code ———————————————————— // //// //////////////////////////////////////////////////////////////////////////////// //———————————————————————————————————————————————————————————————————————————— // Script Configurations /* All of the confgurations below contribute to how the JavaScript imports function. It only works with imports like this, not direct JavaScript code, hence why it is in between here and the mentioned section above. */ //———————————————————————————————————————————————————————————————————————————— ////////////////////////////////////////////////////////////////////////////////

/* AjaxRC settings */ window.ajaxRefresh = 30000; //auto refresh every 30 seconds

/* Show removed replies on threads */ $(".message-removed.hide").removeClass("hide");

/* FastDelete settings */ var fdButtons = []; fdButtons.push({   'summary': 'Housekeeping',    'label': 'HK' });

//////////////////////////////////////////////////////////////////////////////// //// // ——————————————————————— End Configuration Section ———————————————————————— // //// //////////////////////////////////////////////////////////////////////////////// //———————————————————————————————————————————————————————————————————————————— // ImportArticles /* ImportArticles minifies the rest of the JavaScript or CSS code and combines multiple HTTP requests into a single data transfer, making it save space and load faster than direct imports. It is recommended to import this way. */ //———————————————————————————————————————————————————————————————————————————— ////////////////////////////////////////////////////////////////////////////////

/* Staff/VSTF/Bot/Helper highlights */ importStylesheetPage('Highlight/code.css', 'dev');

/* WLB highlights */ importStylesheetPage('MediaWiki:WLBhighlight.css', 'wlb');

/* Imports */ importArticles({   type: "script",    articles: [        'u:dev:MediaWiki:CacheCheck/code.js', //cross out items already done        'u:dev:MediaWiki:HeaderLinks/code.js', //make a icon that when clicked gives a link to the current heading        'u:dev:MediaWiki:NoImageLightbox/code.js', //go to the File: page instead of opening the image in a popup        'u:dev:MediaWiki:MarkBlocked.js', //cross out blocked users        'u:dev:MediaWiki:Wikimarks/code.js', //change the one the wiki menu to something useful        'u:dev:MediaWiki:AjaxRC/code.js', //auto refresh pages        'u:dev:MediaWiki:LastEdited/code.js', //show who last edited the page        'u:dev:MediaWiki:AjaxUndo/code.js', //undo with one click        'u:dev:MediaWiki:FixWantedFiles/code.js', //make links on the WantedFiles page go to the image, not to the editor        'u:dev:MediaWiki:HoverEditCount/code.js', //show editcount when hovering over editcount on global masterhead 'u:dev:MediaWiki:OldFilePages/code.js', //remove the tabs on file pages 'u:dev:MediaWiki:QuickDiff/code.js', //show diffs in a popup 'u:dev:MediaWiki:WHAM/code.2.js', //mass rollback 'u:dev:MediaWiki:MarkForDeletion/code.js', //mark for deletion with one click 'u:dev:MediaWiki:AnchoredRollback/code.js', //don't leave the page when doing a rollback 'u:dev:MediaWiki:Rollback/code.js', //rollback without needing the userright 'u:dev:MediaWiki:ContribsLink/code.js', //add a contribs link in the account nav menu 'u:dev:MediaWiki:DupImageList/code.js', //list duplicate images 'u:dev:MediaWiki:DisplayTimer/code.js', //show a UTC clock in the toolbar, that you can click to purge the page and shift + click to null edit 'u:dev:MediaWiki:FastDelete/code.js', //delete page by clicking on a button 'u:dev:MediaWiki:Linksweeper/code.js', //remove links on pages 'u:dev:MediaWiki:RecentChangesMultiple/code.2.js' //better RecentChanges ] });