משתמש:IKhitron/101.js
הערה: לאחר הפרסום, ייתכן שיהיה צורך לנקות את זיכרון המטמון (cache) של הדפדפן כדי להבחין בשינויים.
- פיירפוקס / ספארי: להחזיק את המקש Shift בעת לחיצה על טעינה מחדש (Reload) או ללחוץ על צירוף המקשים Ctrl-F5 או Ctrl-R (במחשב מק: ⌘-R).
- גוגל כרום: ללחוץ על צירוף המקשים Ctrl-Shift-R (במחשב מק: ⌘-Shift-R).
- אינטרנט אקספלורר / אדג': להחזיק את המקש Ctrl בעת לחיצה על רענן (Refresh) או ללחוץ על צירוף המקשים Ctrl-F5.
- אופרה: ללחוץ על Ctrl-F5.
// done - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 100, 101, 108, 109, 118, 119, 447, 828, 829
// restrict - 0, 1, 2, 3, 4, 5, 6, 10, 12, 100
mw.loader.using( [ 'mediawiki.util', 'mediawiki.api' ] ).then( function() {
var step = 10;
var wait = 1000;
var count;
function postPurge(cat, addParams) {
var apiParams = $.extend({
action: 'purge',
generator: 'allpages',
gapnamespace: 0,
// gapfrom: '',
// gapprtype: 'edit|move|upload',
// gapprlevel: 'templateeditor|sysop',
gaplimit: step,
forcelinkupdate: 1
}, addParams);
new mw.Api().post(apiParams)
.fail(function(d) {
alert("כישלון");
})
.done(function(d) {
console.log(d.purge.length + ": " + d.purge[d.purge.length-1].title);
console.log(d);
count += step;
if (d.warnings === undefined && d["continue"] !== undefined
&& d["continue"].gapcontinue) {
mw.notify(count + " דפים רועננו");
setTimeout(function() {
postPurge(cat, d["continue"]);
}, wait);
} else
alert("הרענון הושלם בהצלחה!");
});
}
if (mw.config.get('wgNamespaceNumber') == 2)
$(mw.util.addPortletLink('p-cactions', '#', 'רענון', 'pt-refresh'))
.click(function() {
count = 0;
postPurge(mw.config.get('wgPageName')
.replace(/_/g, " "));
});
});