User:GeorgeMoney/UserScripts/ClerkAutoTag

//

if(wgPageName.indexOf('Wikipedia:Requests_for_checkuser/Case/') == 0&&wgIsArticle || wgPageName == 'Special:Log') {
	addOnloadHook(function() {
		var tbs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
		addlilink(tbs, "javascript:fix_links()", "prepare for tagging", 'ca-taglinks', 'Alter all the links on this page to autotag the page when clicked');
	});
}

if(location.href.indexOf('action=edit') != -1 && location.href.indexOf('autotag=') != -1) {
	addOnloadHook(function() {
		var tag = _GET('autotag');
		var box = document.getElementById('wpTextbox1');
		var txt = box.value;
		if(txt.toLowerCase().indexOf(tag.toLowerCase()) != -1) {
			var contt = confirm("The requested tag was already found on this page.\nPress ok to continue to add the tag");
			if(!contt) return;
		}
		box.value = tag;
		document.getElementById('wpSummary').value = 'Tagging page with: '+tag;
		document.getElementById('wpMinoredit').checked = 'checked';
		document.getElementById('wpWatchthis').checked = '';
		document.getElementById('wpSave').click();
	});
}

function fix_links() {
	var teer = wgTitle.split('/')[wgTitle.split('/').length - 1];
	var tag = prompt('Please enter the tag you would like to use.\nExample: {'+'{sockpuppetCheckuser|'+teer+'|'+teer+'}'+'}');
	if(tag == null) { alert('Action canceled.'); return; }
	if(tag == "") tag = '{'+'{sockpuppetCheckuser|'+teer+'|'+teer+'}'+'}';
	var links = document.getElementById('bodyContent').getElementsByTagName('a');
	for(var i=0; i<links.length; i++) {
		var link = links[i];
		var cha = (link.href.indexOf('?') != -1) ? '&' : '?';
		link.href += cha + 'linkmodified=yes&action=edit&autotag='+escape(tag);
		link.style.color = "green";
		link.onmouseup = function() { this.style.color = 'orange'; }; 
		link.innerHTML = link.innerHTML.replace(/(<([^>]+)>)/g, '');
	}
	var btn = document.getElementById('ca-taglinks').firstChild;
	btn.href = 'javascript:unfix_links();';
	btn.innerHTML = 'UNprepare for tagging';
	btn.title = '';
}

function unfix_links() {
	var links = document.getElementById('bodyContent').getElementsByTagName('a');
	for(var i=0; i<links.length; i++) {
		var link = links[i];
		link.href = link.href.split('linkmodified=yes')[0];
		link.style.color = "";
	}
	alert('All links will now be safe to click...');
	var btn = document.getElementById('ca-taglinks').firstChild;
	btn.href = 'javascript:fix_links();';
	btn.innerHTML = 'prepare for tagging';
	btn.title = '';
}

//parse paramName out of query string
//stolen from Lupin's popups
function _GET(paramName) {
  var cmdRe=RegExp('[&?]'+paramName+'=([^&]*)');
  var h=document.location;
  var m;
  if (m=cmdRe.exec(h)) {
    try { 
      return unescape(m[1]);
    } catch (someError) {}
  }
  return null;
};
//

Content Disclaimer

Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.

  1. The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
  2. There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
  3. It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
  4. Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
  5. Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.