User:Christo76/js/watchCat.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
This user script seems to have a documentation page at User:Christo76/js/watchCat and an accompanying .css page at User:Christo76/js/watchCat.css. |
/*
|
| author: Kaligula
| license: CC-BY-SA-3.0
| version: 2.3.5
| credits: Matma Rex
| Nux
| _____________________________________________________________________________________
|
| opis działania: [[Wikipedysta:Kaligula/js/watchCat]]
\*_____________________________________________________________________________________*/
//if ( (wgNamespaceNumber==14 && wgAction=='view') || wgPageName=='Specjalna:GadgetPrefs' ) {
addOnloadHook(function () {
importStylesheet('User:Christo76/js/watchCat.css');
$.ajax({
url:location.protocol+'//en.wikipedia.org/wiki/Special:EditWatchlist/raw'
}).done(function(html){
var wList = $(html).find('#mw-input-wpTitles').text();
$('#mw-pages a').each(function(i){
if ( (wList.match(new RegExp('^'+this.innerHTML.replace(/([\(\)\[\]\{\}\|\?\.\*\^\$\+])/g,'\\$1')+'$','m'))!=null) == (watchCat_invert == false)) {
//there's a match and we don't invert selection OR there's no match and we invert selection
$(this).toggleClass('watchCat-main');
}
});
$('#mw-subcategories a').each(function(i){
if ( (wList.match(new RegExp('^'+'Category:'+this.innerHTML.replace(/([\(\)\[\]\{\}\|\?\.\*\^\$\+])/g,'\\$1')+'$','m'))!=null) == (watchCat_invert == false)) {
//there's a match and we don't invert selection OR there's no match and we invert selection
$(this).toggleClass('watchCat-main');
}
});
if (watchCat_pending || watchCat_changed) {
function watchCatPendChanArr() {
var arr=[],j=0,i;
$('#mw-pages a.watchCat-main').each(function(i){
if (i%50==0) { j=i/50; arr[j] = []; }
arr[j].push(this.innerHTML)
})
arr.forEach(function(el, i){ arr[i]=el.join('|'); })
return arr;
}
if (watchCat_changed) {
// function watchCatChan() {
var arr = watchCatPendChanArr();
window.watchCatStamps = {};
window.watchCatChanCounter = 0;
arr.forEach(function(el, i){
$.ajax({
url:location.protocol+'//en.wikipedia.org/w/api.php?action=query&prop=info&format=json&inprop=watched%7Cnotificationtimestamp&indexpageids=&titles=' + encodeURI(arr[i])
}).done(function(data){
watchCatChanCounter++;
data.query.pageids.forEach(function(elm, j){
if (data.query.pages[elm].watched == "") {
watchCatStamps[data.query.pages[elm].title] = (data.query.pages[elm].notificationtimestamp != "");
};
});
if (watchCatChanCounter==arr.length){
$('#mw-pages a.watchCat-main').each(function(){
(watchCatStamps[this.innerHTML]) ? ($(this).toggleClass('watchCat-watched-changed')) : {};
});
}
});
});
// }
}
function watchCatPend() {
var arr = watchCatPendChanArr();
window.watchCatFlags = {};
window.watchCatPendCounter = 0;
arr.forEach(function(el, i){
$.ajax({
url:location.protocol+'//en.wikipedia.org/w/api.php?action=query&indexpageids&prop=flagged&format=json&titles=' + encodeURI(arr[i])
}).done(function(data){
watchCatPendCounter++;
data.query.pageids.forEach(function(elm, j){
watchCatFlags[data.query.pages[elm].title] = ( (!data.query.pages[elm].flagged) ? "watchCat-flagged-unreviewed" : ((data.query.pages[elm].flagged.pending_since) ? "watchCat-flagged-pending" : "watchCat-flagged-reviewed") );
});
if (watchCatPendCounter==arr.length){
$('#mw-pages a.watchCat-main').each(function(index){
$(this).toggleClass(watchCatFlags[this.innerHTML]);
});
}
});
});
}
if (watchCat_pending) {
watchCatPend();
}
else {
$('#mw-pages > p')[0].outerHTML += '\n→ <a href=# onclick="watchCatPend()">Sprawdź wersje oznaczone obserwowanych artykułów</a><br>\n→ Narzędzia zewnętrzne: <a href="http://toolserver.org/~magnus/deep_insight.php?language=pl&category=' + wgTitle + '&depth=10&mode=web&doit=Do+it" class="external text">wersje nieprzejrzane</a>/<a href="http://toolserver.org/~magnus/deep_out_of_sight.php?language=pl&category=' + wgTitle + '&depth=10&mode=web&doit=Do+it" class="external text">wersje oczekujące na ponowne przejrzenie</a>'
}
}
});
});
});
//}