User:Anerisys/vector.js

/* User contributions edit shortcut */

// initialize variables var contribution_day = 0; var contribution_count = 0; var contributions_on_page = 0;

if (	mw.config.get("wgNamespaceNumber") == -1 // checks "Special" name space	&& mw.config.get("wgCanonicalSpecialPageName") == "Contributions" // checks if it is a contributions page	&& document.getElementsByClassName("mw-contributions-list") // contributions list not empty	&& ( ! document.getElementsByClassName("mw-changeslist-links")[1].getElementsByTagName("span")[2] ) // not already added ) {

var mw_contributions_list = document.getElementsByClassName("mw-contributions-list");

for ( contribution_day = 0; contribution_day < mw_contributions_list.length; contribution_day++ ) {

for ( contribution_count = 0; contribution_count < mw_contributions_list[contribution_day].getElementsByTagName("li").length; contribution_count++ ) {

var contribution = mw_contributions_list[contribution_day].getElementsByTagName("li")[contribution_count]; if (contribution.querySelector(".mw-changeslist-links") ) { edit_page_URL = mw.util.getUrl( contribution.querySelector(".mw-contributions-title").innerHTML, { "action": "edit" } ); contribution.querySelector(".mw-changeslist-links").appendChild(document.createElement("span")); contribution.querySelector(".mw-changeslist-links").lastElementChild.classList.add("mw-changeslist-edit"); contribution.querySelector(".mw-changeslist-links").lastElementChild.innerHTML=" edit"; contributions_on_page+=contribution_count; }		}	}	console.log("Showing "+contributions_on_page+" contributions on "+contribution_day+" days."); } else { if (document.getElementsByClassName("mw-changeslist-links")[1].getElementsByTagName("span")[2] ) console.warn("Edit links appear to have already been added."); }