User:Cometstyles/wikia.js

From Meta, a Wikimedia project coordination wiki

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
function getMessage (where, user1, user2) {
	var message = prompt ('What message would you like to leave?', '');
	window.location = '/index.php?title=' + mw.util.getParamValue('title') + '&action=edit&oldid=' + mw.util.getParamValue('oldid') + '&'+where+'=2&user1='+user1+'&user2='+user2+'&message='+message;
}

// <nowiki>
$(function() {
	if (location.href.match(/diff=/)) {
		// Get username of submitter
		var user1 = $('td.diff-otitle:first a:eq(2)').html();
		var user2 = $('td.diff-ntitle:first a:eq(3)').html();
		$('#contentSub').html('(<a href="/index.php?title=' + mw.util.getParamValue('title') + '&action=edit&oldid=' + mw.util.getParamValue('oldid') + '&revert=1&user1='+user1+'&user2='+user2+'">Revert</a> / <a href="javascript:var message = getMessage(\'revert\', \''+user1+'\', \''+user2+'\');">Message</a>) (<a href="/index.php?title=' + mw.util.getParamValue('title') + '&action=edit&oldid=' + mw.util.getParamValue('oldid') + '&vandalism=1&user1='+user1+'&user2='+user2+'">Vandalism</a> / <a href="javascript:var message = getMessage(\'vandalism\', \''+user1+'\', \''+user2+'\');">Message</a>) (Warn: <a href="/index.php?title=User_talk:'+user2+'&action=edit&section=new&warn=1">No content</a> / <a href="/index.php?title=User_talk:'+user2+'&action=edit&section=new&warn=2">Notice</a> / <a href="/index.php?title=User_talk:'+user2+'&action=edit&section=new&warn=3"> 1st Warning</a> / <a href="/index.php?title=User_talk:'+user2+'&action=edit&section=new&warn=4">Blanking</a>)');
	}
	else if (location.href.match(/revert=1/)) {
		$('#wpSummary').val('Reverted edits by [[Special:Contributions/'+mw.util.getParamValue('user2')+'|'+mw.util.getParamValue('user2')+']] to version ' + mw.util.getParamValue('oldid')+' by [[Special:Contributions/'+mw.util.getParamValue('user1')+'|'+mw.util.getParamValue('user1')+']]');
		$('#editform').submit();
	}
	else if (location.href.match(/revert=2/)) {
		$('#wpSummary').val('Reverted edits by [[Special:Contributions/'+mw.util.getParamValue('user2')+'|'+mw.util.getParamValue('user2')+']] to version ' + mw.util.getParamValue('oldid')+' by [[Special:Contributions/'+mw.util.getParamValue('user1')+'|'+mw.util.getParamValue('user1')+']] ('+mw.util.getParamValue('message')+')');
		$('#editform').submit();
	}
	else if (location.href.match(/vandalism=1/)) {
	$('#wpSummary').value = 'Reverted vandalism by [[Special:Contributions/'+mw.util.getParamValue('user2')+'|'+mw.util.getParamValue('user2')+']] to version ' + mw.util.getParamValue('oldid')+' by [[Special:Contributions/'+mw.util.getParamValue('user1')+'|'+mw.util.getParamValue('user1')+']]';
	$('#editform').submit();
	}
	else if (location.href.match(/vandalism=2/)) {
		$('#wpSummary').val('Reverted vandalism by [[Special:Contributions/'+mw.util.getParamValue('user2')+'|'+mw.util.getParamValue('user2')+']] to version ' + mw.util.getParamValue('oldid')+' by [[Special:Contributions/'+mw.util.getParamValue('user1')+'|'+mw.util.getParamValue('user1')+']] ('+mw.util.getParamValue('message')+')');
		$('#editform').submit();
	}
	else if (location.href.match(/warn=1/)) {
		$('#wpSummary').val('No content warning');
		$('#wpTextbox1').val('{{subst:No content}}~~~~');
		$('#editform').submit();
	}
	else if (location.href.match(/warn=2/)) {
		$('#wpSummary').val('Notice');
		$('#wpTextbox1').val('{{subst:Notice}}~~~~');
		$('#editform').submit();
	}
	else if (location.href.match(/warn=3/)) {
		$('#wpSummary').val('Warning');
		$('#wpTextbox1').val('{{subst:Warning|This is your first warning. You have already been notified in the above message to stop. If you continue, you may be banned.}}~~~~');
		$('#editform').submit();
	}
	else if (location.href.match(/warn=4/)) {
		$('#wpSummary').val('Vandalism warning');
		$('#wpTextbox1').val('{{subst:test2a}} ~~~~');
		$('#editform').submit();
	}
});
// </nowiki>

//From http://en.wikipedia.org/w/index.php?title=User:JesseW/monobook.js&oldid=20755510
function addSinceTab() {
	if (window.location.href.indexOf("&action=history&gotosince=true")!=-1) {
		do_since_I_last_edited();
	}
	else if (mw.config.get('wgCanonicalNamespace') != "Special") {
		mw.util.addPortletLink("p-cactions", "/index.php?title="+mw.config.get('wgPageName')+"&action=history&gotosince=true", '', 'diff', "since");
	}
}
function do_since_I_last_edited() {
	var csub=document.getElementById("contentSub");
	var msg=document.createElement("p");
	msg.appendChild(document.createTextNode("Parsing history... please wait..."));
	msg.className="error";
	csub.insertBefore(msg, csub.firstChild);

	var username=document.getElementById("pt-userpage").textContent;
	var hists=document.getElementById("pagehistory").getElementsByTagName('li');
	for (n=0;n<hists.length;n++) {
		if (hists[n].getElementsByTagName("span")[0].getElementsByTagName('a')[0].textContent==username) {
			document.location=hists[n].childNodes[1].href;
			return;
		}
	}

	msg.replaceChild(document.createTextNode("You have not edited this page! (recently)"), msg.firstChild);
}

$(addSinceTab);

// Please leave the following line
// [[user:Where/usertabs]]

$(function() {
	if (mw.config.get('wgTitle').indexOf("/") != -1 || document.title.indexOf("- History -") != -1)  //no subpages or history
		return;
	if (mw.config.get('wgCanonicalNamespace') == "User" || mw.config.get('wgCanonicalNamespace') == "User_talk") {
		var username = encodeURIComponent( mw.config.get('wgTitle') );
		mw.util.addPortletLink("p-cactions", mw.config.get('wgServer') + "/wiki/Special:Contributions/" + username, "Contribs", "ca-contrib", "User contributions");
		mw.util.addPortletLink("p-cactions", "/wiki/Special:Editcount/" + username, "Edit count", "ca-editcount", "Edit count");
		mw.util.addPortletLink("p-cactions", mw.config.get('wgServer') + "/index.php?title=Special:Log&type=move&user=" + username, "Page moves", "ca-pagemoves", "Page moves by this user");
		mw.util.addPortletLink("p-cactions", mw.config.get('wgServer') + "/index.php?title=Special:Log&type=block&page=User:" + username, "Blocks received", "ca-blog", "Blocks received by this user");
		mw.util.addPortletLink("p-cactions", mw.config.get('wgServer') + "/index.php?title=Special:Prefixindex&from=" + username + "&namespace=2", "Userspace", "", "List of pages in this user's userspace");
		mw.util.addPortletLink("p-cactions", mw.config.get('wgServer') + "/index.php?title=Special:Log&type=block&user=" + username, "Blocks given", "", "Blocks by this user");
		mw.util.addPortletLink("p-cactions", mw.config.get('wgServer') + "/index.php?title=Special:Log&type=protect&user=" + username, "Protections", "", "Protections by this user");
		mw.util.addPortletLink("p-cactions", mw.config.get('wgServer') + "/index.php?title=Special:Log&type=delete&user=" + username, "Deletions", "", "Deletions by this user");
	}
});

/**
 * Ajax sysop
 * @see https://meta.wikimedia.org/wiki/Ajax_sysop
 * @update-token [[File:pathoschild/ajaxsysop.js]]
 */
mw.loader.load('//tools-static.wmflabs.org/meta/scripts/pathoschild.ajaxsysop.js');