User:King Lopez/monobook.js
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.
importScript('User:AzaToth/twinkle.js');
// [[User:Lupin/popups.js]]
importScript('User:Lupin/popups.js');
//<pre><nowiki>
// Add date and time to your monobook "personal menu" list at the very top of the page.
// Created by [[User:Mathwiz2020]]
// Indicate where you would like the time to appear:
// 1 is first (before username), 2 is second (before talk link), ... 7 is last (after log out link)
insertBeforeNum = 7;
// Do NOT edit below this line unless you're experiened in javascript
insertBeforeArr = new Array("","pt-userpage","pt-mytalk","pt-preferences","pt-watchlist","pt-mycontris","pt-logout","");
insertBefore = insertBeforeArr[insertBeforeNum];
function makeTime()
{
var li = document.createElement( 'li' );
li.id = 'pt-time';
var mySpan = document.createElement( 'span' );
mySpan.appendChild( document.createTextNode( 'date and time' ) );
li.appendChild( mySpan );
if ( insertBefore )
{
var before = document.getElementById( insertBefore );
before.appendChild( li, before );
}
else // append to end (right) of list
{
document.getElementById( 'pt-logout' ).parentNode.appendChild( li );
}
getTime();
}
if ( window.addEventListener ) window.addEventListener ( 'load', makeTime, false );
else if ( window.attachEvent ) window.attachEvent ( 'onload', makeTime );
function getTime()
{
var time = new Date();
var date = time.getUTCDate();
var months = 'Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec'.split(' ');
month = months[time.getUTCMonth()];
var year = time.getUTCFullYear();
var hours = '0' + time.getUTCHours();
hours = hours.substr(hours.length-2, hours.length);
var minutes = '0' + time.getUTCMinutes();
minutes = minutes.substr(minutes.length-2, minutes.length);
var seconds = '0' + time.getUTCSeconds();
seconds = seconds.substr(seconds.length-2, seconds.length);
var curTime = hours + ":" + minutes + ":" + seconds + ", " + date + " " + month + " " + year + " (UTC)";
datePlace = document.getElementById('pt-time').childNodes[0].childNodes[0];
datePlace.replaceData(0, datePlace.length, curTime);
doTime = window.setTimeout("getTime()", 1000);
}
//</nowiki></pre>
/* <pre> */
function welcome() {
// Find the edit box
var txt = document.editform.wpTextbox1;
//The welcome *template* you want to use
var welcome_template = 'w-screen';
var welcome_summary = 'Welcome';
var welcome_watch = false;
// The tag to be included is a welcome message
var tag = '{{subst:'+ welcome_template +'}}';
// If the edit box doesn't already have this tag...
if (txt.value.indexOf(tag) == -1) {
// Append the tag
txt.value += tag;
// Add an edit summary
document.editform.wpSummary.value = welcome_summary;
document.editform.wpWatchthis.checked = welcome_watch;
// Press the Save page button
document.editform.submit();
}
// If the tag was already there, turn the tab background red to indicate
// that the script is functioning properly, but that there is no action
// to do. This doesn't interrupt the user's work like an alert() would.
else {
document.getElementById('ca-unverified').firstChild.style.backgroundColor = "#ff4444";
document.getElementById('ca-unverified').style.backgroundColor = "#ff4444";
}
}
// Create a tab that calls this function when pressed
// Create a tab that calls this function when pressed
addOnloadHook(
function ()
{
if(document.title.indexOf("Editing User talk:") == 0)
{
mw.util.addPortletLink('p-cactions', 'javascript:welcome()', 'welcome', 'ca-welcome', 'Adds a welcome note to a new user', '', '');
}
}
);
/* This is to keep track of who is using this extension: [[User:King Lopez/welcome_newuser.js]] */
/* </pre> */
// <pre><nowiki>
addOnloadHook(function() {
if (wgTitle.indexOf("/") != -1 || document.title.indexOf("- History -") != -1) //no subpages or history
return;
if (wgCanonicalNamespace == "User" || wgCanonicalNamespace == "User_talk") {
var username = encodeURIComponent( wgTitle );
mw.util.addPortletLink("p-cactions", wgServer + "/wiki/Special:Contributions/" + username, "contribs", "ca-contrib", "User contributions");
mw.util.addPortletLink("p-cactions", "http://tools.wikimedia.de/~interiot/cgi-bin/Tool1/wannabe_kate?username=" + username + "&site=en.wikipedia.org", "count", "ca-editcount", "Edit count from Interiot's Tool1");
mw.util.addPortletLink("p-cactions", "http://www.math.ucla.edu/~aoleg/wp/rfa/edit_summary.cgi?user=" + username + "&site=en.wikipedia.org", "Summary", "ca-summary", "Edit Summary");
}
});
// </nowiki></pre>
// See [[{{TALKPAGENAME}}|Talk page]] <pre>
if (wgNamespaceNumber >= 0)
addOnloadHook(function(){
var pCactions = document.getElementById('p-cactions');
if (!pCactions) return;
var caMain = pCactions.getElementsByTagName('li')[0];
var caTalk = document.getElementById('ca-talk');
var caEdit = document.getElementById('ca-edit');
if (!caEdit) caEdit = document.getElementById('ca-viewsource');
var caHistory = document.getElementById('ca-history');
if (!caMain || !caTalk || !caEdit || !caHistory) return;
var el_move, el_create, id2;
if (wgNamespaceNumber % 2) { //talk space
el_move = caTalk; el_create = caMain; id2 = '';
} else {
el_move = caMain; el_create = caTalk; id2 = 'discussion';
}
caEdit.firstChild.innerHTML = 'edit';
caHistory.firstChild.innerHTML = 'hist';
el_move.parentNode.insertBefore(caHistory, el_move.nextSibling);
el_move.parentNode.insertBefore(caEdit, el_move.nextSibling);
var href = el_create.firstChild.getAttribute('href', 2);
if (el_create.className.indexOf('new') < 0){
mw.util.addPortletLink('p-cactions', href + '?action=history', 'hist',
'ca-history-'+id2, id2+' history', '', el_create.nextSibling);
mw.util.addPortletLink('p-cactions', href + '?action=edit', 'edit',
'ca-edit-'+id2, 'Edit '+id2, '', el_create.nextSibling);
}
caMain.style.marginRight = '0.3em';
caTalk.style.marginRight = '0.3em';
caTalk.style.marginLeft = '1.6em';
})
// </pre>
/*<pre>*/
//On diff pages this script replaces ''(Difference between revisions)''with
//different tools for reverting the edit and warning the user that made the edit.
//For instructions see talk page.
// Revert tools by Lorian
function getElementsByClass(searchClass,node,tag) {
// Function from http://www.dustindiaz.com/getelementsbyclass/
var classElements = new Array();
if ( node == null )
node = document;
if ( tag == null )
tag = '*';
var els = node.getElementsByTagName(tag);
var elsLen = els.length;
var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
for (i = 0, j = 0; i < elsLen; i++) {
if ( pattern.test(els[i].className) ) {
classElements[j] = els[i];
j++;
}
}
return classElements;
}
// _GET code from NoGray JS Library http://www.nogray.com/new_site/
var _GET = new Array();
var _uri = location.href;
var _temp_get_arr = _uri.substring(_uri.indexOf('?')+1, _uri.length).split("&");
var _temp_get_arr_1 = new Array();
for(_get_arr_i=0; _get_arr_i<_temp_get_arr.length; _get_arr_i++){
_temp_get_arr_1 = _temp_get_arr[_get_arr_i].split("=");
_GET[decodeURI(_temp_get_arr_1[0])] = decodeURI(_temp_get_arr_1[1]);
}
delete _uri; delete _temp_get_arr; delete _temp_get_arr_1;
function getMessage (where, user1, user2) {
var message = prompt ('What message would you like to leave?', '');
window.location = 'http://en.wikipedia.org/w/index.php?title=' + _GET['title'] + '&action=edit&oldid=' + _GET['oldid'] + '&'+where+'=2&user1='+user1+'&user2='+user2+'&message='+message;
}
addOnloadHook(function (){
if (location.href.match(/diff=/)) {
// Get username of submitter
var user1 = getElementsByClass('diff-otitle',null,'td'); user1 = user1[0].getElementsByTagName('a')[2].innerHTML;
var user2 = getElementsByClass('diff-ntitle',null,'td'); user2 = user2[0].getElementsByTagName('a')[3].innerHTML;
document.getElementById('contentSub').innerHTML = '(<a href="http://en.wikipedia.org/w/index.php?title=' + _GET['title'] + '&action=edit&oldid=' + _GET['oldid'] + '&revert=1&user1='+user1+'&user2='+user2+'">Revert</a> / <a href="javascript:var message = getMessage(\'revert\', \''+user1+'\', \''+user2+'\');">Message</a>) (<a href="http://en.wikipedia.org/w/index.php?title=' + _GET['title'] + '&action=edit&oldid=' + _GET['oldid'] + '&vandalism=1&user1='+user1+'&user2='+user2+'">Vandalism</a> / <a href="javascript:var message = getMessage(\'vandalism\', \''+user1+'\', \''+user2+'\');">Message</a>) (Warn: <a href="http://en.wikipedia.org/w/index.php?title=User_talk:'+user2+'&action=edit§ion=new&warn=1">Test</a> / <a href="http://en.wikipedia.org/w/index.php?title=User_talk:'+user2+'&action=edit§ion=new&warn=2">Blatant</a> / <a href="http://en.wikipedia.org/w/index.php?title=User_talk:'+user2+'&action=edit§ion=new&warn=3">Nonsense</a> / <a href="http://en.wikipedia.org/w/index.php?title=User_talk:'+user2+'&action=edit§ion=new&warn=4">Blanking</a>)';
} else if (location.href.match(/revert=1/)) {
document.getElementById('wpSummary').value = 'Reverted edits by [[Special:Contributions/'+_GET['user2']+'|'+_GET['user2']+']] to version ' + _GET['oldid']+' by [[Special:Contributions/'+_GET['user1']+'|'+_GET['user1']+']]';
document.getElementById('editform').submit();
} else if (location.href.match(/revert=2/)) {
document.getElementById('wpSummary').value = 'Reverted edits by [[Special:Contributions/'+_GET['user2']+'|'+_GET['user2']+']] to version ' + _GET['oldid']+' by [[Special:Contributions/'+_GET['user1']+'|'+_GET['user1']+']] ('+_GET['message']+')';
document.getElementById('editform').submit();
} else if (location.href.match(/vandalism=1/)) {
document.getElementById('wpSummary').value = 'Reverted vandalism by [[Special:Contributions/'+_GET['user2']+'|'+_GET['user2']+']] to version ' + _GET['oldid']+' by [[Special:Contributions/'+_GET['user1']+'|'+_GET['user1']+']]';
document.getElementById('editform').submit();
} else if (location.href.match(/vandalism=2/)) {
document.getElementById('wpSummary').value = 'Reverted vandalism by [[Special:Contributions/'+_GET['user2']+'|'+_GET['user2']+']] to version ' + _GET['oldid']+' by [[Special:Contributions/'+_GET['user1']+'|'+_GET['user1']+']] ('+_GET['message']+')';
document.getElementById('editform').submit();
} else if (location.href.match(/warn=1/)) {
document.getElementById('wpSummary').value = 'Vandalism warning';
document.getElementById('wpTextbox1').value = '{{sub'+'st:test}} ~~'+'~~';
document.getElementById('editform').submit();
} else if (location.href.match(/warn=2/)) {
document.getElementById('wpSummary').value = 'Vandalism warning';
document.getElementById('wpTextbox1').value = '{{sub'+'st:blatantvandal}} ~~'+'~~';
document.getElementById('editform').submit();
} else if (location.href.match(/warn=3/)) {
document.getElementById('wpSummary').value = 'Vandalism warning';
document.getElementById('wpTextbox1').value = '{{sub'+'st:test2}} ~~'+'~~';
document.getElementById('editform').submit();
} else if (location.href.match(/warn=4/)) {
document.getElementById('wpSummary').value = 'Vandalism warning';
document.getElementById('wpTextbox1').value = '{{sub'+'st:test2a}} ~~'+'~~';
document.getElementById('editform').submit();
}
});
/*</pre>*/
// <pre><nowiki>
// Please leave the following line
// [[user:Where/usertabs]]
addOnloadHook(function() {
if (wgTitle.indexOf("/") != -1 || document.title.indexOf("- History -") != -1) //no subpages or history
return;
if (wgCanonicalNamespace == "User" || wgCanonicalNamespace == "User_talk") {
var username = encodeURIComponent( wgTitle );
mw.util.addPortletLink("p-cactions", wgServer + "/w/index.php?title=Special:Log&type=block&page=User:" + username, "Block log", "ca-blog", "Blocks received by this user");
}
});
// </nowiki></pre>
importScript("User:Lupin/recent2.js");
importScript('User:TheJosh/Scripts/NewPagePatrol.js');