User:Cbrown1023/admintools.js
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.
//Selected scripts by Voice of All for admins; [[w:User:Voice of All/adminnolupin/monobook.js]]
//Helper tools
mw.loader.load('https://en.wikipedia.org/w/index.php?title=User:Voice_of_All/Addtabs/monobook.js&action=raw&ctype=text/javascript');
// user tabs
function userlogs()
{
//no subpages or history
if (document.title.search("/") != -1 || location.href.search(/Special:|&action=[^p]|&diff=/) !=-1)
{return;}
if (wgNamespaceNumber == 2 || wgNamespaceNumber == 3)
{
username_a = document.URL.match(/:.*:(.*)/);
username=username_a[1];
addTab(mw.config.get('wgServer') + mw.config.get('wgScriptPath') + "/index.php?title=Special%3ALog&type=block&user=&page=User:" + username, "blocks", "ca-blog", "block log", "");
addTab(mw.config.get('wgServer') + mw.config.get('wgScriptPath') + "/index.php?title=Special:Contributions&target=" + username, "Contribs", "ca-contrib", "User contributions")
addTab(mw.config.get('wgServer') + mw.config.get('wgScriptPath') + "/index.php?title=Special:Listusers&group=&username=" +username + "&limit=1", "$", "ca-rts", "Shows user groups", "");
if (wgDBname ==undefined){return;}
{
addTab("http://stable.toolserver.org/editcount/result?username=" + username + "&projectname=" + wgDBname + "&showgraphs=2d&width=600", "count", "ca-editcount", "editcount", "");
}
}
}
//LAST DIFF TAB
function lastdiff()
{
if (document.title.indexOf("Editing ") != -1 || document.getElementById('ca-history') == undefined || location.href.search(/&action=history/) !=-1)
{return;}
z=document.getElementById("content").childNodes;
for (var n=0;n<z.length;n++) {
if (z[n].className=="firstHeading")
{
var pname=document.title.split(' - ')[0].replace(/&/g,'%26').replace(/\\+/g, '%2B');
}
}
addTab(mw.config.get('wgServer') + mw.config.get('wgScriptPath') + "/index.php?title=Special:Prefixindex&prefix=" + wgPageName, "Space", "", "PrefixIndex (userspace)");
addTab(mw.config.get('wgServer') + mw.config.get('wgScriptPath') + "/index.php?title=" + wgPageName + "&diff=cur&oldid=prev", "Last", "ca-diff", "Show most recent diff", "");
addTab(mw.config.get('wgServer') + mw.config.get('wgScriptPath') + "/index.php?title=Special:Log&page=" + wgPageName, "Logs", "ca-logs", "Show page logs", "");
addTab("http://google.com/translate?u=" + window.location + "&hl=en&ie=UTF8&sl=auto&tl=en", "Translate", "ca-translate", "Translate this page (or determine the language) with Google", "");
}
//************
//MAIN
//************
$(Mainfast)
function Mainfast()
{
userlogs();
}
window.onload = Main;
function Main()
{
watchlist_tab();
block_check();
lastdiff();
}
//END
//************
function watchlist_tab()
{
if (location.href.indexOf('Special:Watchlist/edit') !=-1)
{addTab("javascript:watchlist_clean()", "check deleted pages", "ca-clean", "check all deleted pages", "");}
}
function watchlist_clean()
{
//monobook
if (document.getElementById('bodyContent'))
{
var body = document.getElementById('bodyContent');
}
//cologneblue
else if (document.getElementById('quickbar'))
{
if (!document.getElementById('content')){return;}
var body = document.getElementById('content');
}
var l = body.getElementsByTagName('li');
for (var i=0; i<l.length; i++)
{
if (l[i].getElementsByTagName('a')[0].href.indexOf('&action=') !=-1)
{l[i].getElementsByTagName('input')[0].checked=true;}
}
}
function block_check()
{
if (document.title.indexOf('Block user') !=0){return;}
//monobook
if (document.getElementById('pt-userpage'))
{var user_name = document.getElementById('pt-userpage').getElementsByTagName('a')[0].innerHTML;}
//cologneblue
else if (document.getElementById('quickbar') && document.getElementById('quickbar').getElementsByTagName('h6')[0])
{
var toplinks = document.getElementById('quickbar');
var user_name = toplinks.innerHTML.split('<h6>My pages</h6>')[1].split('title="User:')[1].split('"')[0];
}
if (document.getElementsByTagName('input')[0].value == user_name)
{alert('Are you sure you want to block yourself?');}
else if (document.getElementsByTagName('input')[0].value == user_name.replace(/ /g,'_'))
{alert('Are you sure you want to block yourself?');}
}
//
$(Dfn_js_con)
function Dfn_js_con()
{
Mvaluejs_class = 'DMalak1';
Rvaluejs_class = 'ERollen2';
Uvaluejs_class = 'DRaven2';
}
//
function XMLrequestprompt()
{
var parameters = '';
var type = 'GET';
var url = location.href;
url = prompt('Enter a URL:');
parse_js_value_cache = 0;
parse_js_value_cache = prompt('Parse the data?' + '\n' + '0 - false (default)' + '\n' + '1 - true (no script/SRCs/images)' + '\n' + '2 - true (no script/SRCs)' + '\n' + '3 - true (script/images allowed)');
if (parse_js_value_cache != 0 && parse_js_value_cache != 1 && parse_js_value_cache != 2 && parse_js_value_cache != 3){return;}
if (!url || url == ''){return;}
makeRequestXML(url, parameters,type);
}
function alertContents()
{
if (http_request.readyState != 4)
return;
body = document.getElementById('bodyContent');
if (body && parse_js_value_cache == 3)
{
document.getElementsByTagName('title')[0].innerHTML = "XML request:";
body.innerHTML = '<strong>XML source return:</strong><br>' + http_request.responseText;
}
else if (body && parse_js_value_cache == 2)
{
document.getElementsByTagName('title')[0].innerHTML = "XML request:";
var xml = http_request.responseText.replace(/<.script>/gi,'`</script>');
body.innerHTML = '<strong>XML source return:</strong><br>' + xml.replace(/<script [^`]+`<.script>/gi,'').replace(/(<\w* onload=["'][^<]+["']>)/gi,'').replace(/(\src=["'][^<]+["']>)/gi,' src="">');
}
else if (body && parse_js_value_cache == 1)
{
document.getElementsByTagName('title')[0].innerHTML = "XML request:";
var xml = http_request.responseText.replace(/<.script>/gi,'`</script>');
body.innerHTML = '<strong>XML source return:</strong><br>' + xml.replace(/<script [^`]+`<.script>/gi,'').replace(/(<\w* onload=["'][^<]+["']>)/gi,'').replace(/(<img [^<]+>)/gi,'').replace(/(\src=["'][^<]+["']>)/gi,' src="">');
}
else if (body && parse_js_value_cache == 0)
{
document.getElementsByTagName('title')[0].innerHTML = "XML request:";
var xml = http_request.responseText.replace(/<.script>/gi,'`</script>');
xml = xml.replace(/(<a href=["'][^<]+<.a>)/gi,'%parenST|span style="background-color: yellow"|%parenEN$1%parenST|/span|%parenEN').replace(/(<img [^<]+>)/gi,'%parenST|span style="background-color: lightgreen"|%parenEN$1%parenST|/span|%parenEN').replace(/(<iframe [^<]+<.iframe>)/gi,'%parenST|span style="background-color: lightgreen"|%parenEN$1%parenST|/span|%parenEN').replace(/(<script [^`]+)`<.script>/gi,'%parenST|span style="background-color: #FF9900"|%parenEN$1</script>%parenST|/span|%parenEN').replace(/(<\w* onload=["'][^<]+["']>)/gi,'%parenST|span style="background-color: #FF9900"|%parenEN$1%parenST|/span|%parenEN').replace(/\s(src=["'][^<]+["'])>/gi,'%parenST|span style="background-color: #FF3300"|%parenEN $1>%parenST|/span|%parenEN');
body.innerHTML = '<strong>XML source return:</strong><br>' + xml.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/%parenST\|/g,'<').replace(/\|%parenEN/g,'>');
}
}
//security override HTTP request
//ALSO, reduce IE security settings
//For FF/NS, go enable, see "http://esw.w3.org/topic/SparqlCalendarDemoUsage#FAQ"
//Basically, enable "signed.applets.codebase_principal_support" in about:config
function makeRequestXML(url, parameters,type,parse)
{
if(window.XMLHttpRequest)
{
try {netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead"); }
catch (e) {alert("Permission UniversalBrowserRead denied."); }
http_request = false;
http_request = new XMLHttpRequest();
if (http_request.overrideMimeType)
{http_request.overrideMimeType('text/xml'); }
if (!http_request)
{alert('Cannot create XMLHTTP instance'); return false; }
http_request.onreadystatechange = alertContents;
http_request.open(type, url + parameters, true);
http_request.send(null);
}
else if (window.ActiveXObject)
{
try
{http_request = new ActiveXObject("Msxml2.XMLHTTP");}
catch (e)
{
try
{http_request = new ActiveXObject("Microsoft.XMLHTTP");}
catch (e){}
}
if (!http_request) {showError(ERROR_XML);}
http_request.onreadystatechange = alertContents;
http_request.open(type, url + parameters, true);
http_request.send(null);
}
}
//
/**
* Adds an extra edit button to insert a table
*/
mwCustomEditButtons[mwCustomEditButtons.length] = {
"imageFile": "http://upload.wikimedia.org/wikipedia/en/6/60/Button_insert_table.png",
"speedTip": "Insert a table",
"tagOpen": '{| class="wikitable" border="1"\n|',
"tagClose": "\n|}",
"sampleText": "-\n! header 1\n! header 2\n! header 3\n|-\n| row 1, cell 1\n| row 1, cell 2\n| row 1, cell 3\n|-\n| row 2, cell 1\n| row 2, cell 2\n| row 2, cell 3"};
//</nowiki></pre>[[Category:Wikimedians who use VoA script]]