Jump to content

User:Sock of Steel359/unblock.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
// <pre>

function addLink(where, url, name, id, title, key, after) {
    // addLink() accepts either an id or a DOM node, addPortletLink() only takes a node
    if (after && !after.cloneNode)
        after = document.getElementById(after);

    return addPortletLink(where, url, name, id, title, key, after);
}

//  if (document.title.indexOf("Editing User talk:") != -1) {


// -----------------------------------------------------------------------------------------------------------

function declineunblock()
{
  var reason1 = prompt("Reason for declining?");
  if ( !reason1 ) {
  return;
 } else {
  var url = wgServer + '/wiki/' + wgPageName + '?action=edit';
  window.open(url);
  var f = document.editform, t = f.wpTextbox1;
  var unblock = RegExp("\{\{[U|u]nblock\|(.*?)\}\}");
  var reviewed = RegExp("\{\{Unblock reviewed|1=$1|decline=");
  t.value = t.value.split(unblock).join(reviewed + decline + "}}");
  document.forms[0].wpDiff.click();
 }
}

function declineunblock_tagging()
{
  addPortletLink('p-interaction', 'javascript:declineunblock()', "Decline unblock");
}

$(declineunblock_tagging);

// -----------------------------------------------------------------------------------------------------------

$(function (){
  if(queryString("jsaction")=="decline") {
  var reason1 = prompt("Reason for declining?");
  if ( !reason1 ) {
  return;
 } else {
  var f = document.editform, t = f.wpTextbox1;
  var unblock = RegExp("\{\{[U|u]nblock\|(.*?)\}\}");
  var reviewed = "{"+"{Unblock reviewed|1=" + $1 + "|decline=" + reason1 + "}}";
  t.value = t.value.split(unblock).join(reviewed);
  document.forms[0].wpDiff.click();
 }
}
});

	function queryString(p) {
		var re = RegExp('[&?]' + p + '=([^&]*)');
		var matches;
		if (matches = re.exec(document.location)) {
			try { 
				return decodeURI(matches[1]);
			} catch (e) {
			}
		}
		return null;
	};

//}
// </pre>