User:Chlod/Scripts/Deputy.js: Difference between revisions

Content deleted Content added
(bot/CD)
(bot/CD)
Line 351:
 
var version = "0.8.0";
var gitAbbrevHash = "fa061834441faf";
var gitBranch = "main";
var gitDate = "FriMon, 724 Jun 2024 2300:3658:1548 +0800";
var gitVersion = "0.8.0+gfa06183g4441faf";
 
/**
Line 1,142:
*
* @param sectionHeading
* @param sectionHeadingPredicate A function which returns `true` if the section should stop here
* @return Section headings.
*/
Line 1,229:
const heading = normalizeWikiHeading(el);
return heading != null &&
// Require that this heading is already normalized.
// TODO: Remove at some point.
// This shouldn't be required if double-normalization wasn't a thing.
el === heading.h &&
// eslint-disable-next-line security/detect-non-literal-regexp
Line 1,292 ⟶ 1,295:
const heading = normalizeWikiHeading(sectionHeading);
const ceiling = heading.root.parentElement;
return getSectionElements(heading.root, (el) => { var _a, _b; return heading.level >= ((_b = (_a = normalizeWikiHeading(el, ceiling)) === null || _a === void 0 ? void 0 : _a.level) !== null && _b !== void 0 ? _b : Infinity); });
var _a, _b;
// TODO: Avoid double normalization
const norm = normalizeWikiHeading(el, ceiling);
return (heading.level >= ((_a = norm === null || norm === void 0 ? void 0 : norm.level) !== null && _a !== void 0 ? _a : Infinity)) ||
this.isContributionSurveyHeading((_b = norm === null || norm === void 0 ? void 0 : norm.h) !== null && _b !== void 0 ? _b : el);
});
}
/**
Line 4,189 ⟶ 4,198:
let dateReverseScore = 1;
let byteScore = 1;
let dateStreak = 0;
let dateReverseStreak = 0;
let byteStreak = 0;
for (const diff of diffs) {
if (last == null) {
Line 4,196 ⟶ 4,208:
const diffTimestamp = new Date(diff.timestamp).getTime();
const lastTimestamp = new Date(last.timestamp).getTime();
dateScore// =The (dateScoreuse +of (diffTimestampthe >OR lastTimestampoperator ?here 1has :a 0))specific / 2;purpose:
dateReverseScore// =* (dateReverseScoreOn +the (diffTimestampfirst <iteration, lastTimestampwe ?want 1all :streak 0))values /to 2;be 1
byteScore// =* (byteScoreOn +any (diff.diffsizeother <iteration, last.diffsizewe ?want 1it :to 0))increment /the streak by 1 if a 2;streak
// exists, or set it to 1 if a streak was broken.
dateStreak =
diffTimestamp > lastTimestamp ? dateStreak + 1 : 0;
dateReverseStreak =
diffTimestamp < lastTimestamp ? dateReverseStreak + 1 : 0;
byteStreak =
diff.diffsize <= last.diffsize ? byteStreak + 1 : 0;
dateScore = (dateScore + ((diffTimestamp > lastTimestamp ? 1 : 0) * (1 + dateStreak * 0.3))) / 2;
dateReverseScore = (dateReverseScore + ((diffTimestamp < lastTimestamp ? 1 : 0) * (1 + dateReverseStreak * 0.3))) / 2;
byteScore = (byteScore + ((diff.diffsize <= last.diffsize ? 1 : 0) * (1 + byteStreak * 0.3))) / 2;
last = diff;
}
}
// Multiply by weights to remove ties
dateScore *= 1.105;
dateReverseScore *= 1.05025;
switch (Math.max(dateScore, dateReverseScore, byteScore)) {
case byteScore: