User:Ahecht/Scripts/refresh.js: Difference between revisions

Content deleted Content added
better status
Sync from sandbox, add "dir" and "shuffle" options
Line 7:
var pageList = [];
const reuse = ( typeof refreshReuseBubble === 'undefined' ? false : refreshReuseBubble );
function shuffleArray(array) {
console.log('Shuffling array...');
for (let i = array.length - 1; i >= 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[array[i], array[j]] = [array[j], array[i]];
}
}
function getWait(d, totalCount) {
Line 51 ⟶ 59:
var err = error?.textStatus || code;
var errMsg;
//if (confirm("Error performing " + action + ": " + err + "!\n\nContinue?") == true) {
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' } );
Line 78 ⟶ 86:
var numPages = wait.edit < 1000 ? 3 : 1;
apiParams.titles = pageList.splice(0, numPages).join('|');
console.log(apiParams.titles);
apiParams.forcerecursivelinkupdate = "1";
//apiParams.forcelinkupdate = "1";
Line 83 ⟶ 92:
} else {
apiParams.title = pageList.shift();
console.log(apiParams.title);
apiParams.watchlist = "nochange";
apiParams.nocreate = "1";
Line 99 ⟶ 109:
target,
addParams);
var list = target?.list || "pages";
if (queryParams.cmdir && window.refreshOrder) queryParams.cmdir = window.refreshOrder;
console.log(queryParams);
new mw.Api().post(queryParams).fail(function(code, error) {
console.error(error);
alert("Error fetching page titles: " + code + "!");
} ).done(function(q) {
if(q && q.warnings === undefined && q?.query?.[list] &&!== q.query.pagesundefined) {
for (var page in q.query[list].pages)forEach(page => {
if (qpage.querytitle) pageList.pages[push(page].title) {;
});
pageList.push(q.query.pages[page].title);
if (q["?.continue?.continue"] !== undefined ) {
}
getList(action, target, q[".continue"]);
}
if (q["continue"] !== undefined
&& (q["continue"].gticontinue
|| q["continue"].gcmcontinue
|| q["continue"].glhcontinue
)
) {
getList(action, target, q["continue"]);
} else {
if (window.refreshShuffle) shuffleArray(pageList);
console.log(pageList);
new mw.Api().get( {
Line 169 ⟶ 176:
} else {
query = {
generatorlist: 'categorymembers',
gcmtitlecmtitle: target,
gcmlimitcmlimit: 'max',
cmsort: 'timestamp',
cmdir: 'desc'
};
linkTitle = "category members";