User:Minato826/global.js

/* Imports from Dev */ importArticles({   type: "script",    articles: [        "u:dev:AjaxPatrol/code.js",        "u:dev:RedirectManagement/beta.js",        "u:dev:QuickCreateUserPage/code.js",        "u:dev:QuickCreateMessageWallGreeting/code.js"    ] });

/*self import */ importArticles({   type: "script",    articles: [        'u:the-last-tycoon:User:Minato826/wikia.js'        ] });

/* view removed comments */ importArticles({   type: 'script',    articles: [        'u:dev:ViewRemovedAlways/code.js'    ] });

importArticles({   type: "script",    articles: [        'u:dev:AjaxBatchDelete/code.2.js'    ] });

/*recent change from dev*/ importArticles({   type: "script",    articles: [        "u:dev:RecentChangesMultiple/code.2.js"    ] });

/*fast delete from dev*/ importArticles( {   type: 'script',    articles: [        'u:dev:Rollback/code.js',       ] } );

$( document ).ready( function { mw.util.addPortletLink( 'p-personal', mw.util.wikiGetlink('Special:NewPagesFeed'), 'Page Curation', 'pt-pagecuration', 'View Special:New Pages using the Page Curation tool', null, '#pt-preferences' ); });

//Turns rollback links into AJAX rollback links //By BenjaminWillJS

function SetAjaxRollback { $('a.mw-rollback-link').click(function(e) {		e.preventDefault;		var $rblink = $(this);		var href = this.getElementsByTagName('a')[0].href;		this.innerHTML = ' ';		$.ajax({ url: href, success: function { $rblink.text(function (i, val) {return val + ' [success]';}); loadPageData; },			error: function { $rblink.text(function (i, val) {return val + ' [failed]';}); loadPageData; }		});	}); }

// This script reimpliments the last edit banner used on mobile // See User:Opencooper/lastEdit // TODO: standardize on either single or double quotes

function requestRevision { // If we're not reading an article, do nothing if (!(mw.config.get( 'wgAction' ) === 'view' && mw.config.get( 'wgIsArticle' ) && mw.config.get("wgPageName") !== "Main_Page")) { return; }

// API docs: https://www.mediawiki.org/wiki/API:Revisions $.ajax({       url: "https://en.wikipedia.org/w/api.php?action=query&prop=revisions&format=json&titles="             + mw.config.get('wgPageName')             + "&rvprop=timestamp%7Cuser%7Ccomment%7Ctags%7Cids",        success: displayEdit    }); }

// Display the last edit info to the right of the site subhead function displayEdit(response) { var pageId = mw.config.get('wgArticleId'); var pageInfo = response.query.pages[pageId].revisions[0]; // Relies on moment.js. See script history for an inline implementation var relativeTimestamp = moment(pageInfo.timestamp).fromNow;

var editComment = pageInfo.comment; if (!editComment) { editComment = "[No edit summary]"; }   editComment = editComment.replace(/'/g, "&#39;"); // HTML encode quotes

var lastEdit = " Last edited " + relativeTimestamp + ""; var lastEditor = "" + pageInfo.user + ""; // Can be filtered if needed var pageTags = ""; if (pageInfo.tags.length > 0) { pageTags = " (" + pageInfo.tags + ") "; }

var notice = lastEdit + " by " + lastEditor + pageTags;

// MediaWiki:Gadget-metadata.js replaces the siteSub element so wait for it   // to run first // Check if script is enabled and if it hasn't ran already if ($("script").text.search("ext.gadget.metadata") != -1 && !$(".assess-article-rating").length) { var target = document.querySelector('#siteSub'); var observer = new MutationObserver(function(mutations) { // IE 11+           $('#siteSub').append(" " + notice + " ");            observer.disconnect;        });

observer.observe(target, {childList: true}); } else { $('#siteSub').append(" " + notice + " "); }

// Unfortunately Template:Coords absolutely positions itself so we have // to move it down so we don't get obscured var sheet = window.document.styleSheets[0]; sheet.insertRule('#coordinates { top: 2em !important; }', sheet.cssRules.length); }

$(requestRevision);