Content deleted Content added
Undid revision 1237088885 by Ahecht (talk) meant to edit sandbox |
increase number of pages purged at a time |
||
Line 8:
const reuse = ( typeof refreshReuseBubble === 'undefined' ? false : refreshReuseBubble );
function getWait(d
var wait=
if (d && d?.query
if (d.query.userinfo.rights
&& d.query.userinfo.rights.includes("noratelimit")) {
wait = {edit: 1, purge: 1};
} else if (
['edit', 'purge'].forEach ( (v) => {
console.log(v + " rate limit: hits=" + u.hits + ", seconds=" + u.seconds);
if (u.hits < totalCount) {
{▼
▲ var hits = d.query.userinfo.ratelimits[type].user.hits;
console.log(
wait[v] = 1;
▲ if (hits < totalCount) {
▲ wait = Math.ceil( (seconds/hits) * 1000 );
}
} );▼
▲ wait = 1;
▲ }
}
}
console.log("
return wait;
}
Line 40 ⟶ 39:
setTimeout(function() {
doRefresh(action, count, totalCount, wait);
}, wait[action]);
} else if (confirm("Done!\n\nReload page?") == true) {
document.___location.reload();
} else {
mw.notify("Done!", {type: 'success', tag: "bubble" + (reuse ? 0 : 'done')});
}
}
Line 48 ⟶ 49:
function postFail(code, error) {
console.error(error);
var err = error?.textStatus || code;
if (confirm("Error performing " + action + ":" + code + "!\n\nContinue?") == true) {▼
var errMsg;
errMsg = "Continuing after "+err+" error...";
postDone();
} else {
errMsg = "Aborted due to "+err+" error!";
}
mw.notify(errMsg, { tag: "bubble" + (reuse ? 0 : "error"), type: 'error',
autoHideSeconds: (action == 'purge') ? 'long' : 'short' } );
}
function postSuccess() {
count = count + ( (action == "purge") ? ((apiParams.titles.match(/\|/g) || []).length + 1) : 1 );
mw.notify(
tag: "bubble" + autoHideSeconds: (action == 'purge') ? 'long' : 'short'
} );
postDone();
}
Line 62 ⟶ 73:
if (action == "purge") {
var numPages = Math.round(wait.purge/wait.edit) || 1;
apiParams.titles = pageList.
apiParams.forcerecursivelinkupdate = "1";
new mw.Api().post(apiParams).fail(postFail).done(postSuccess);
Line 107 ⟶ 119:
} ).fail( function(e) {
console.error(e);
doRefresh(action, 0, pageList.length,
} ).done( function(ui) {
mw.notification.autoHideLimit = len;
mw.notify('Performing '+action+' on '+len+' page(s)...', {
autoHideSeconds: (action == 'purge') ? 'long' : 'short',
tage: 'bubble0'
} );
doRefresh(action, 0, len, getWait(ui, len));
} );
}
|