User:SuperSajuuk/wikia.js

// // Personal JS: SuperSajuuk // Last Modified: 10th May 2015, 20:12 // // This is a personal testing ground for various // JS and jQuery enhancements coded by // SuperSajuuk. You may copy any code below to your // own wikia.js files. // // Any jQuery/JS requests should be posted on // my talkpage. // // Enjoy! //

(function (window, $, mw) {       "use strict";        // This adds an attribute to make linking the reply box easier...        $("li.new-reply").attr("id","replybox");

// Add an "Edit Page" link on archives. var page = wgTitle; var pieces = page.search("Archive"); if(pieces > -1) { $(".WikiaPageHeader h2 a").last.after(' |  Edit This Archive'); }       // Redirect the popup uploader to Special:Upload $(window).load(function {              $("a.wikia-button.upphotos").click(function { setTimeout(function {                           window.location.href = "/wiki/Special:Upload";                      },2500); });       });

// Add a notice on Special:Forum /* $("section#Forum > a.policies-link").first.before("" + " Welcome to the Narutopedia Community Forums! This is where you can discuss the series and the wiki itself. " + "Before contributing to the forums, please read our forum policies: they are simple to understand. You can find them by clicking the button to the right. " + " Please note that the wiki's general policies apply at all times, such as the Image Policy. " + "Any moderator requests should be directed to the Requests page " + " Failure to heed our policies will result in written warnings, followed by wiki blocks if repeatedly ignored. " + " "); */ // Some forum cleanup. $("section.blurb").attr("style","width: auto;font-size: small;"); $(".blurb p").last.append($(".policies-link")); $(".policies-link").after($(".admin-link")).text("Forum Policy"); // $(".admin-link").attr("style","margin: -15px;margin-right: -103px").text("Manage"); $("a:contains('Old forum Archives')").remove; // Menu links. mw.util.addPortletLink("AccountNavigation", "/wiki/User:SuperSajuuk/DPL", "DPL", "p-dpl"); mw.util.addPortletLink("AccountNavigation", "/wiki/Special:UserRights", "Manage Rights", "p-userrights"); }(window, jQuery, mediaWiki));

// Quick identification of closed/highlighted threads $(function {   if (mw.config.get('wgNamespaceNumber') !== 2000) {        return;    }    // Loop to add padlock/exclamation.    function update {        $('.ThreadList .thread').each(function { var $this = $(this); // Formatting fix $this.find('a').css("display","inline"); // With many thanks to w:User:Cqm! $.get(mw.util.wikiScript('wikia'), {               controller: 'Forum',                method: 'brickHeader',                id: $this.data('id'),                format: 'json'            }, function(data) {                if (data.isClosed) {                    $this.find('h4 > a').before(' ');                }                if (data.isNotifyeveryone) {                    $this.find('h4 > a').before(' ');                }            }); });   };    // Run it!    update;    // Make sure it works on all pages, not just page 1.    var observer = new MutationObserver(function(mutations) { mutations.forEach(function(mutation) {           if (mutation.addedNodes.length || mutations.removedNodes.length) {                update;            }        }); });   observer.observe($('.ThreadList')[0], { childList: true }); });