User:Yair rand/superwatchlist.js
Jump to navigation
Jump to search
Note: You may have to bypass your browser’s cache to see the changes. In addition, after saving a sitewide CSS file such as MediaWiki:Common.css, it will take 5-10 minutes before the changes take effect, even if you clear your cache.
- Mozilla / Firefox / Safari: hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (Command-R on a Macintosh);
- Konqueror and Chrome: click Reload or press F5;
- Opera: clear the cache in Tools → Preferences;
- Internet Explorer: hold Ctrl while clicking Refresh, or press Ctrl-F5.
- This script lacks a documentation subpage. Please create it.
- Useful links: root page • root page’s subpages • links • redirects • your own
// interwiki watchlist
wgPageName == "Special:Watchlist" && 'localStorage' in window && jQuery(document).ready(function(){
var v=document.getElementById("mw-watchlist-options");
v = v.parentNode.insertBefore(newNode('div'), v.nextSibling)
for(var k = localStorage['importedwatchlists'+wgUserName]?localStorage['importedwatchlists'+wgUserName].split("|"):[], ii=0; ii < k.length; ii++){
function st(rt){
var tkn = localStorage['importedwatchlist'+wgUserName+rt+'token'], project = "http://"+rt+".org/";
JsMwApi(project + "w/api.php")({action:'query',list:'watchlist',wlowner:wgUserName,wltoken:tkn,
wlexcludeuser:wgUserName,wlprop:'title|flags|user|parsedcomment|timestamp|ids'},function(r){t=r
var b=newNode('ul',{'style':'display:'+
(localStorage['importedwatchlist'+wgUserName+rt+'hidden']?'none;':'block;')
});
v.parentNode.insertBefore(b, v.nextSibling);
v.parentNode.insertBefore(newNode('h3',project+" watchlist", newNode('span',{'style':'font-size:12px;'},' [',newNode('a','Remove',{style:'cursor:pointer;',click:function(){
localStorage.removeItem('importedwatchlist'+wgUserName+rt+'token');
localStorage['importedwatchlists'+wgUserName] = localStorage['importedwatchlists'+wgUserName].replace(rt,'').replace(/(^\||\|\||\|$)/,'');
location.reload()
}}),'] [',newNode('a',localStorage['importedwatchlist'+wgUserName+rt+'hidden']?'Expand ▼':'Collapse ▲',{'style':'cursor:pointer;','click':function(){
if(b.style.display=='none'){
b.style.display='block';
this.innerHTML="Collapse ▲"
localStorage['importedwatchlist'+wgUserName+rt+'hidden'] = ""
}
else{
b.style.display='none';
this.innerHTML="Expand ▼"
localStorage['importedwatchlist'+wgUserName+rt+'hidden'] = true
}
}}),']')), v.nextSibling);
var g=r.query.watchlist;
for(var i = 0; i < g.length; i++){
var zx = newNode('span',{class:'comment'}); zx.innerHTML = ' ('+g[i].parsedcomment+')';
b.appendChild(newNode('li','(',
newNode('a','diff',{href:project+"w/index.php?title="+g[i].title+"&curid="+g[i].pageid+"&diff="+g[0].revid}),
' | ',
newNode('a','hist',{href:project+"w/index.php?title="+g[i].title+"&curid="+g[i].pageid+"&action=history"}),
') . . ',
newNode('a',g[i].title,{href:project+"wiki/"+g[i].title}),
'; '+g[i].timestamp.match(/\d\d\:\d\d/)[0]+' . . ',
g[i].user,
zx
))
}
})
}
st(k[ii])
}
var qw, er=['Wikipedia','Wiktionary','Wikibooks','Wikisource','Wikiquote','Wikiversity','Wikinews','Meta-Wiki','Commons','Wikispecies','Mediawiki'], cv, bn;
document.getElementById('firstHeading').appendChild(newNode('a',"Import watchlist",{'style':'padding-left:10px;cursor:pointer; float:right; font-size: 13px;',click:function(){
v.innerHTML='';
v.appendChild(newNode('form',
{'style':'display:inline;','submit':function(){
var importedurl=(qw.value > 6?(qw.value==7?"meta.wikimedia":qw.value==8?'commons.wikimedia':qw.value==9?'species.wikimedia':'mediawiki'):cv.value+'.'+er[qw.value].toLowerCase())
localStorage['importedwatchlists'+wgUserName] = (localStorage['importedwatchlists'+wgUserName]?localStorage['importedwatchlists'+wgUserName]+"|":"")+importedurl;
localStorage['importedwatchlist'+wgUserName+importedurl+'token']=bn.value;
location.reload()
return false}},
'Language: ',cv=newNode('input',{size:3}),
' Project: ', qw=newNode('select'), newNode('br'),
'Watchlist token ',newNode('small','(can be found be found at ',newNode('a','Special:Preferences',{'href':'http://en.wikipedia.org/wiki/Special:Preferences#preftab-5'}),' in the Watchlist section)'),': ',bn=newNode('input'),
newNode('input',{'type':'submit','value':'Import watchlist'})));
for(var i = 0; i < er.length; i++){qw.appendChild(newNode('option',{'value':i},er[i]))};
}}))
document.getElementById('firstHeading').appendChild(newNode('a',"Click here to enable watchlist notifications",{'style':'float:right; font-size: 13px;',click:function(){webkitNotifications.requestPermission(); this.innerHTML = 'Click "Allow" and then refresh the page.'}}))
})