/*
<pre> <nowiki>
Note: After saving, you have to bypass your browser's cache to see the changes.
To do this in Firefox/Mozilla/Safari: hold down Shift while clicking Reload,
or press Ctrl-Shift-R).
If you use Internet Explorer: press Ctrl-F5, Opera/Konqueror: press F5.
</nowiki> </pre>
==AzaToth's reversion tools ==
<pre> <nowiki> */
// importScript('User:AzaToth/twinkle.js');
/*
</nowiki> </pre>
==WikEd, replaces Firefox's text edit window ==
<pre> <nowiki> */
// install ] in-browser text editor
document.write('<script type="text/javascript" src="'
+ 'http://en.wikipedia.org/w/index.php?title=User:Cacycle/wikEd.js'
+ '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
</nowiki> </pre>
*/
importScript('User:Lupin/recent2.js');
/*
== Watchlist sorter ==
<pre> <nowiki>
Sorts your watchlist by namespace, and also adds spaces for readability.
*/
$(function (){
if (location.href.indexOf('Special:Watchlist') == -1) return; //Are we on a watchlist?
//days = document.getElementById('bodyContent').getElementsByTagName('ul');
days = document.evaluate( //Hell knows how it works - found in "Dive into Greasemonkey"
"//ul",
document,
null,
XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
null);
for (d = 0; d < days.snapshotLength; d++) { //For each day
day = days.snapshotItem(d);
newday = document.createElement('ul'); //This will replace the old listing
while ((diffs = day.getElementsByTagName('li')).length > 0) { //Are there any diffs left?
//Try to extract the namespace
As = diffs.getElementsByTagName('a');
if (As.innerHTML == 'diff')
pagename = As.innerHTML;
else
pagename = As.innerHTML;
if (pagename.indexOf(':') == -1)
namespace = 'Main';
else
namespace = pagename.split(':'); //This will fail for articles which contain ":" in name
hdrs = newday.getElementsByTagName('h5'); //Get the list of namespace headers
hdr = null;
for (j=0; j<hdrs.length; j++) //Find the header
if (hdrs.innerHTML==namespace) {
hdr = hdrs; break;
}
if (hdr==null) { //Not found? Make a new one!
hdr = document.createElement('h5');
hdr.innerHTML = namespace;
newday.appendChild(hdr);
namespacesub = document.createElement('ul');
newday.appendChild(namespacesub);
}
hdr.nextSibling.appendChild(diffs); //Move the diff
}
newday.appendChild(document.createElement('hr')); //For readablility
day.parentNode.replaceChild(newday,day);
}
});
/*** BEGIN WIKIBREAK ENFORCER ***/
$(function() {
/*** Start editing here ***/
// When you want to end your break?
// no leading zeroes. (example: 7 - correct, 07 - incorrect)
var date = { year: 2010, month: 4, day: 5 };
var time = { hours: 20, minutes: 22, seconds: 0 };
/*** Stop editing here ***/
var currentDate = new Date();
var enforcedBreakEnd = new Date(
date.year,date.month,date.day,time.hours,time.minutes,time.seconds);
if (currentDate <= enforcedBreakEnd) {
alert("Enforced wikibreak until "+enforcedBreakEnd.toLocaleString()
+ "\n(now is "+currentDate.toLocaleString()+")\n\nBye!");
location = "http://"+location.host+"/w/index.php?title="
+ "Special:Userlogout&returnto=Main_Page";
}
});
/*** END WIKIBREAK ENFORCER ***/mw.loader.load('//en.wikipedia.org/w/index.php?title=User%3ALupin%2Fautoedit.js&action=raw&ctype=text/javascript'); // ]
//Greasemonkey can't seem to be able to access the embedded variables such as wgUserName
//unless you do this. This make it easy to tell if you're logged in, much simpler than
//checking the edit token.
var cdata = eval(document.getElementsByTagName("script").innerHTML);
//This punts you to the login page if you try to make an anon edit.
if(wgAction=="edit" && wgUserName==null) location.href = wgServer + wgScript +
"?title=Special:UserLogin&returnto=" + wgPageName;
/* Templates Used finder, version
Originally from: http://en.wikipedia.orghttps://wikifreehand.com/en/User:Splarka/temused.js
Notes:
* Uses the API using head/appendchild(script) and callback to avoid ajax.
* Redesigned a-la http://en.wikipedia.orghttps://wikifreehand.com/en/User:Splarka/templatesabused.js (which is for edit mode)
** This script is for view mode. Similar display, completely different method of operation.
*/
if(wgNamespaceNumber != -1 && wgArticleId > 0 && wgAction == 'view') addOnloadHook(findTemButton)
function findTemButton() {
var portlet = (window.temusedIAmATool) ? 'p-tb' : 'p-cactions';
mw.util.addPortletLink(portlet,'javascript:findTem()','Templates used','ca-tem');
if(queryString('findtem')=='true') findTem();
}
function findTem() {
var bar = document.getElementById('contentSub') || document.getElementById('topbar');
if(!bar) return;
var div = document.createElement('div');
div.setAttribute('id','tem-out');
bar.appendChild(div);
injectSpinner(div,'tem');
var url = mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '/api.php?maxage=0&smaxage=0&format=json&callback=findTemCB&action=query&generator=templates>llimit=500&prop=revisions&indexpageids&titles=' + encodeURIComponent(mw.config.get('wgPageName')) ;
mw.loader.load(url);
}
function findTemCB(obj) {
var tem = document.getElementById('tem-out');
removeSpinner('tem');
if(!obj || !obj) {
tem.appendChild(document.createTextNode('error, or no templates found'));
return;
}
appendCSS('#ca-tem a {display:none;} #tem-out {border:1px solid #777777;} .tem-week {color:black;} .tem-day {font-weight:bold;} .tem-hour {color:red;}');
var ul = document.createElement('ul');
var ids = obj;
for(var i=0;i<ids.length;i++) {
if(parseInt(]) < 0) continue
var page = obj];
var title = page;
if(!page) continue
var rev = page;
var li = document.createElement('li');
var ts = rev || 0;
var now = new Date();
var tsd = new Date();
tsd.setISO8601(ts);
var timesince = Math.floor((now - tsd)/1000);
if(timesince == '') timesince = -1;
addLinkChild(li,wgScript + '?curid=' + page,title);
if(timesince > 604800) li.className = 'tem-stale';
li.appendChild(document.createElement('br'));
li.appendChild(document.createTextNode('Last edited: '));
var span = document.createElement('span');
span.appendChild(document.createTextNode(duration(timesince,2)));
span.className = 'tem-time'
if(timesince < 604800) span.className += ' tem-week'
if(timesince < 86400) span.className += ' tem-day'
if(timesince < 3600) span.className += ' tem-hour'
li.appendChild(span)
li.appendChild(document.createTextNode(' ago by '));
addLinkChild(li, wgScript + '?title=Special:Contributions/' + encodeURIComponent(rev),rev);
li.appendChild(document.createTextNode(' ('));
addLinkChild(li, wgScript + '?diff=' + rev,'diff',false,false,'diff=' + rev);
li.appendChild(document.createTextNode(') '));
if(rev) li.appendChild(document.createTextNode(rev))
ul.appendChild(li);
}
tem.appendChild(ul);
}
function addLinkChild(obj,href,text,id,classes,title) {
if(!obj || !href || !text) return false;
var a = document.createElement('a');
a.setAttribute('href',href);
a.appendChild(document.createTextNode(text));
if(id) a.setAttribute('id',id);
if(classes) a.setAttribute('class',classes);
if(title) a.setAttribute('title',title);
obj.appendChild(a);
return a;
}
function queryString(p) {
var re = RegExp('' + p + '=(*)');
var matches;
if (matches = re.exec(document.location)) {
try {
return decodeURI(matches);
} catch (e) {
}
}
return null;
}
//ISO 8601 date module by Paul Sowden, licensed under AFL.
Date.prototype.setISO8601 = function(string) {
if(!string) return
var regexp = '({4})(-({2})(-({2})(T({2}):({2})(:({2})(\.(+))?)?(Z|(()({2}):({2})))?)?)?)?';
var d = string.match(new RegExp(regexp));
if(d.length < 1) return
var offset = 0;
var date = new Date(d, 0, 1);
if(d) date.setMonth(d - 1)
if(d) date.setDate(d)
if(d) date.setHours(d)
if(d) date.setMinutes(d)
if(d) date.setSeconds(d)
if(d) date.setMilliseconds(Number('0.' + d) * 1000)
if(d) {
offset = (Number(d) * 60) + Number(d);
offset *= ((d == '-') ? 1 : -1);
}
offset -= date.getTimezoneOffset();
time = (Number(date) + (offset * 60 * 1000));
this.setTime(Number(time));
}
function duration(input,depth) {
var num = input;
var out = '';
var s = num % 60; num = Math.floor(num / 60);
var m = num % 60; num = Math.floor(num / 60);
var h = num % 24; num = Math.floor(num / 24);
var d = num % 7; num = Math.floor(num / 7);
var w = num % 52; num = Math.floor(num / 52);
var y = num
if(y > 0) out += y + 'yrs '
if(y + w > 0) out += w + 'wks '
if(y + w + d > 0) out += d + 'days '
if(y + w + d + h > 0) out += h + 'hrs '
if(y + w + d + h + m > 0) out += m + 'mins '
out += s + 'secs';
if(depth && depth < out.split(' ').length) {
out = out.split(' ').slice(0,depth).join(' ');
}
return out;
}
//<source lang="javascript">
$(function(){
if (location.href.indexOf('Special:Watchlist') == -1) return; //Are we on a watchlist?
//days = document.getElementById('bodyContent').getElementsByTagName('ul');
days = document.evaluate( //Hell knows how it works - found in "Dive into Greasemonkey"
"//ul",
document,
null,
XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
null);
for (d = 0; d < days.snapshotLength; d++) { //For each day
day = days.snapshotItem(d);
newday = document.createElement('ul'); //This will replace the old listing
while ((diffs = day.getElementsByTagName('li')).length > 0) { //Are there any diffs left?
//Try to extract the namespace
As = diffs.getElementsByTagName('a');
if (As.innerHTML == 'diff')
pagename = As.innerHTML;
else
pagename = As.innerHTML;
if (pagename.indexOf(':') == -1)
namespace = 'Main';
else
namespace = pagename.split(':'); //This will fail for articles which contain ":" in name
hdrs = newday.getElementsByTagName('h5'); //Get the list of namespace headers
hdr = null;
for (j=0; j<hdrs.length; j++) //Find the header
if (hdrs.innerHTML==namespace) {
hdr = hdrs; break;
}
if (hdr==null) { //Not found? Make a new one!
hdr = document.createElement('h5');
hdr.innerHTML = namespace;
newday.appendChild(hdr);
namespacesub = document.createElement('ul');
namespacesub.className = "special";
newday.appendChild(namespacesub);
}
hdr.nextSibling.appendChild(diffs); //Move the diff
}
newday.appendChild(document.createElement('hr')); //For readablility
day.parentNode.replaceChild(newday,day);
}
});
//</source>]
importScript("User:Gerbrant/hidepane.js");
importScript("Wikipedia:Dazzle!/code.js");
$(function() {
var editTab = document.getElementById("ca-edit");
if (!editTab) return;
var editURL = editTab.getElementsByTagName("a").href;
mw.util.addPortletLink("p-cactions", editURL + "&externaledit=true", "EE", "ca-exted", "External editor", "");
});
$(function() {
var editTab = document.getElementById("ca-edit");
if (!editTab) return;
var editURL = editTab.getElementsByTagName("a").href;
mw.util.addPortletLink("p-cactions", editURL + "&externaledit=true", "EE", "ca-exted", "External editor", "");
});
importScript('User:Gary King/expand hidden templates.js'); // ]
importScript('Wikipedia:WikiProject User scripts/Scripts/Six tabs');
defaultdiffs = 750; // or whatever number, see script for details
importScript('Wikipedia:WikiProject User scripts/Scripts/Changes since I last edited');
importScript('User:Anomie/util.js');
importScript('User:Anomie/linkclassifier.js'); // Linkback: ]
importScript('User:Ale_jrb/Scripts/userhist.js'); //]
importScript('User:PleaseStand/userinfo.js');// ]