Jack_who_built_the_house added a comment.
@1F616EMO In the worker context, `node` is domhandler's Element <https://domhandler.js.org/classes/Element.html> with some props and methods <https://github.com/jwbth/convenient-discussions/blob/ed2f4914da68f6de83eadfb0012ca54e414e88e5/src/shared/domhandler.d.ts#L83> I added for uniformity. It doesn't have the `matches` method. `innerText` and `nodeName` I've just added as aliases for `textContent` and `tagName`. On the one hand, in the worker context, you don't //really// need the precision you need in the window context. The page is parsed in the worker solely to check for new and changed comments. So you may simply add a check like `'matches' in node` or `node instanceof Element` before calling `node.matches`. The only case where this will make a difference is when an element that matches `_rejectNodeMatches` is added before a comment. In this case, CD will think it was edited and show a corresponding note. So, I asked Claude Sonnet 4.6 Extended Thinking <https://claude.ai/share/3512810b-6891-447f-a3ae-d61e8463ae3a> to generate a replacement code without `matches()` and checked if the props it uses exist in the our worker context. The result is quite lengthy, but you can use it if you want. 'rejectNode': function (node) { // 優良、典範條目投票期模板匹配 if (node.nodeName === 'DL' && node.innerText.match( /^投票期:.*\n下次可提名.*起/s)) { return true; } // .memo-rfcmakepublic if (node.classList.contains('memo-rfcmakepublic')) return true; // .dykentry if (node.classList.contains('dykentry')) return true; const parent = node.parentElement; const isInArchiveTop = ( parent?.nodeName === 'DIV' && parent.classList.contains('archived') && parent.classList.contains('archive-top') ); if (isInArchiveTop) { // div.archived.archive-top > dl:first-of-type if (node.nodeName === 'DL') { let sibling = node.previousElementSibling; let isFirstDl = true; while (sibling) { if (sibling.nodeName === 'DL') { isFirstDl = false; break; } sibling = sibling.previousElementSibling; } if (isFirstDl) return true; } // div.archived.archive-top > dl:first-of-type ~ hr if (node.nodeName === 'HR') { let sibling = node.previousElementSibling; while (sibling) { // Any preceding DL must be (or precede) the first-of-type DL if (sibling.nodeName === 'DL') return true; sibling = sibling.previousElementSibling; } } } // p.notice if (node.nodeName === 'P' && node.classList.contains('notice')) return true; return false; }, TASK DETAIL https://phabricator.wikimedia.org/T409653 EMAIL PREFERENCES https://phabricator.wikimedia.org/settings/panel/emailpreferences/
_______________________________________________ pywikibot-bugs mailing list -- [email protected] To unsubscribe send an email to [email protected]
