Fix comment anchor detection for tracker placement

This commit is contained in:
2026-02-26 00:09:52 +01:00
parent 233355319e
commit 2824392149

View File

@@ -272,8 +272,6 @@ function findCommentSectionAnchorInPost(postElement, actionAnchor = null) {
'[aria-label*="most relevant" i]',
'[aria-label*="neueste" i]',
'[aria-label*="newest" i]',
'[aria-label*="kommentare" i]',
'[aria-label*="comments" i]',
'[aria-roledescription*="kommentar" i]',
'[aria-roledescription*="comment" i]',
'[data-testid*="comment" i]',
@@ -287,7 +285,7 @@ function findCommentSectionAnchorInPost(postElement, actionAnchor = null) {
const anchors = new Set();
postElement.querySelectorAll(selectors.join(', ')).forEach((candidate) => {
if (!candidate || candidate.closest('.fb-tracker-ui')) {
if (!candidate || candidate.closest('.fb-tracker-ui') || !isElementVisible(candidate)) {
return;
}
@@ -299,11 +297,17 @@ function findCommentSectionAnchorInPost(postElement, actionAnchor = null) {
|| candidate;
}
const anchor = getTopLevelAnchorWithinPost(postElement, anchorSeed);
if (!anchor || anchor === actionAnchor) {
let anchor = getTopLevelAnchorWithinPost(postElement, anchorSeed);
if (anchor === actionAnchor) {
anchor = anchorSeed;
}
if (!anchor || anchor === actionAnchor || !anchor.parentElement) {
return;
}
if (actionAnchor && !isNodeAfter(anchor, actionAnchor)) {
const anchorIsInsideAction = Boolean(actionAnchor && actionAnchor.contains(anchor));
if (actionAnchor && !anchorIsInsideAction && !isNodeAfter(anchor, actionAnchor)) {
return;
}