User:Quibik/EightRequestsHelper.js

// To use this script, place "importScript( 'User:Quibik/EightRequestsHelper.js' ); // User:Quibik/EightRequestsHelper.js" // to the bottom of the page opened by http://en.wikipedia.org/wiki/Special:MyPage/vector.js // This will add a link "Update Eight Requests" to the menu next to the search box, if you are on the Eight Requests page.

function eightRequestsHelper {

if (/erhelper=init/i.test(location.href)) { //window.open("/w/index.php?title=Wikipedia:Graphics_Lab/Photography_workshop/Eight_Requests/Users_log&action=edit&erhelper=process", "ER User Log"); window.open("/w/index.php?title=Wikipedia:Graphics_Lab/Photography_workshop/Eight_Requests/Archive/" + (new Date).getFullYear + "&action=edit&erhelper=process", "ER Archive"); window.open("http://commons.wikimedia.org/wiki/User:Quibik/Files_by_viewcounts", "Files by viewcounts"); }

if (/\/Eight_Requests/i.test(location.href) && mw.config.get( 'wgAction' ) === 'edit') { if (!/\/Eight_Requests\//i.test(location.href)) { // Replace the completed requests with empty fields var m = /<!--COPY.+\s*("				);				jQuery("#wpSummary").val("Archived the most recent set. (using a script)");				jQuery("#wpDiff").click;			}			else if (/\/Eight_Requests\/Users_log/i.test(location.href)) {				// Update the user log				var re = /^\|\s*{{User\|\s*([^}]+)\s*}}\s*\|\|\s*(\d+)\s*$/mig;				var m;				while (true) {					m = re.exec(jQuery("#wpTextbox1").val);					if (!m)						break;					m[1] = jQuery.trim(m[1]);					counts[m[1]] = (counts.hasOwnProperty(m[1]) ? counts[m[1]] : 0) + parseInt(m[2]);				}				var names = [];				for(var name in counts){					names.push(name);				}				names.sort;				userList = ""				for (x in names) {					name = names[x];					userList += "|-\n| || " + counts[name] + "\n";				}				jQuery("#wpTextbox1").val(jQuery("#wpTextbox1").val					.replace(/\|-[\s\S]+\|}\n\n==/i, userList + "|}\n\n==")					.replace(/as of \d.+/im, "as of. Updated by "));				jQuery("#wpSummary").val("Updated. (using a script)");				jQuery("#wpDiff").click;			}		});	} } }

$( document ).ready( function {	if (/\/Eight_Requests/i.test(location.href))		mw.util.addPortletLink ( "p-cactions", "/w/index.php?title=Wikipedia:Graphics_Lab/Photography_workshop/Eight_Requests&action=edit&erhelper=init", "Update Eight Requests", "ca-eightRequestsHelper");	if (/erhelper=/i.test(location.href))		eightRequestsHelper; } );