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

Content deleted Content added
(bot/CD)
(bot/CD)
Line 351:
 
var version = "0.6.0";
var gitAbbrevHash = "80a82f71e99f84";
var gitBranch = "main";
var gitDate = "SatSun, 243 FebMar 2024 1114:5134:1031 +0800";
var gitVersion = "0.6.0+g80a82f7g1e99f84";
 
/**
Line 854:
*/
function sectionHeadingName(element) {
var _a, _b;
try {
// Get only the direct text of .mw-headline
return (_b = (_a = element.querySelector('.mw-headline')) === null || _a === void 0 ? void 0 : _a.innerText) !== null && _b !== void 0 ? _b : element.innerText;
// Why? Because DiscussionTools inserts a [subscribe] link in the .mw-headline
// element, which we don't want to include in the section name.
const headlineElement = element.querySelector('.mw-headline');
const headlineDirectText = Array.from((_a = headlineElement === null || headlineElement === void 0 ? void 0 : headlineElement.childNodes) !== null && _a !== void 0 ? _a : [])
.filter(n => n.nodeType === Node.TEXT_NODE)
.reduce((acc, n) => acc + n.textContent, '')
.trim();
return headlineDirectText || (headlineElement === null || headlineElement === void 0 ? void 0 : headlineElement.innerText);
}
catch (e) {