Użytkownik:Polskacafe/autoRC.js: Różnice pomiędzy wersjami
Z Nonsensopedii, polskiej encyklopedii humoru
Polskacafe (dyskusja • edycje) M (wywali się?) |
Polskacafe (dyskusja • edycje) |
||
Linia 22: | Linia 22: | ||
}); |
}); |
||
} |
} |
||
if (document.cookie.indexOf('autoRC=enabled') !== -1) { $('.mw-specialpage-summary'). |
if (document.cookie.indexOf('autoRC=enabled') !== -1) { $('.mw-specialpage-summary').before('<span style="float:right;">AutoRC <input type="checkbox" data-id="autoRC" checked /></span>'); } else { |
||
$('.mw-specialpage-summary').after('<span style="float:right;">AutoRC <input type="checkbox" data-id="autoRC"/></span>'); |
$('.mw-specialpage-summary').after('<span style="float:right;">AutoRC <input type="checkbox" data-id="autoRC"/></span>'); |
||
} |
} |
Aktualna wersja na dzień 18:42, 3 kwi 2022
/*
AutoRC – poor AjaxRC
Author: Sir Polskacafe
Works with all skins
[PL] Informacja dla User:Polskacafe/autoRC.js na nonsa.pl: Wersja może zawierać drobne zmiany i być na bieżąco aktualizowana. Jak chcesz, to sobie kopiuj, ale pamietaj, że mogłeś trafić akurat na zjebaną wersję.
*/
;(function (window, $, mw, undefined) {
window.autoRCPages = ['Specjalna:Ostatnie_zmiany', 'Special:RecentChanges']
if (window.autoRCPages.indexOf(mw.config.get('wgPageName')) === -1) return;
function autoRefresh(window, $, mw) {
var apiurl = 'https://' + window.location.hostname + '/api.php';
var apiparams = { action: "query", format: "json", list: 'recentchanges', rcprop: "ids", rclimit: 1 };
if (!($("a[data-keys='hidebots']").attr('data-params') === "{\"hidebots\":1}")) {
apiparams["rcshow"] = "!bot";
}
$.post( apiurl, apiparams )
.done(function( data ) {
if (document.cookie.indexOf(data.query.recentchanges[0].rcid) === -1) {
document.cookie = 'latestRcid=' + data.query.recentchanges[0].rcid;
window.location.reload();
}
});
}
if (document.cookie.indexOf('autoRC=enabled') !== -1) { $('.mw-specialpage-summary').before('<span style="float:right;">AutoRC <input type="checkbox" data-id="autoRC" checked /></span>'); } else {
$('.mw-specialpage-summary').after('<span style="float:right;">AutoRC <input type="checkbox" data-id="autoRC"/></span>');
}
$("input[data-id='autoRC']").change(function() {
if(this.checked) {
document.cookie = "autoRC=enabled; expires=Thu, 18 Dec 2137 12:00:00 UTC";
setInterval(function() {autoRefresh(window, $, mw);}, 5000);
} else {
document.cookie = "autoRC=disabled; expires=Thu, 18 Dec 2137 12:00:00 UTC";
window.location.reload();
}
});
if (document.cookie.indexOf('autoRC=enabled') !== -1) {
setInterval(function() {autoRefresh(window, $, mw);}, 5000);
}
}(window, $, mw));