From e28eb052b748ba414f7c1c97342789eeef3a658d Mon Sep 17 00:00:00 2001 From: Meik Date: Thu, 26 Feb 2026 00:52:17 +0100 Subject: [PATCH] Prioritize tracker placement above comment composer --- extension/content.js | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/extension/content.js b/extension/content.js index c9ad1a2..5e0a3da 100644 --- a/extension/content.js +++ b/extension/content.js @@ -615,13 +615,22 @@ function positionTrackerInsertionMarker(postElement, marker, buttonBar, postNum return false; } + const commentComposerAnchor = findCommentComposerAnchorInPost(postElement); + if (commentComposerAnchor && commentComposerAnchor.parentElement) { + commentComposerAnchor.parentElement.insertBefore(marker, commentComposerAnchor); + setTrackerInsertionMarkerLocked(marker, true); + console.log('[FB Tracker] Post #' + postNum + ' - Marker inserted before comment composer'); + return true; + } + const resolvedButtonBar = resolveActionButtonBar(postElement, buttonBar); const actionAnchor = getDirectActionAnchorInPost(postElement, resolvedButtonBar); const commentBoundary = findCommentBoundaryAnchorInPost(postElement, actionAnchor); - if (actionAnchor && commentBoundary && commentBoundary.parentElement && isNodeAfter(commentBoundary, actionAnchor)) { + if (commentBoundary && commentBoundary.parentElement) { commentBoundary.parentElement.insertBefore(marker, commentBoundary); setTrackerInsertionMarkerLocked(marker, true); + console.log('[FB Tracker] Post #' + postNum + ' - Marker inserted before comment boundary'); return true; } @@ -643,13 +652,6 @@ function positionTrackerInsertionMarker(postElement, marker, buttonBar, postNum return true; } - if (commentBoundary && commentBoundary.parentElement) { - commentBoundary.parentElement.insertBefore(marker, commentBoundary); - setTrackerInsertionMarkerLocked(marker, true); - console.log('[FB Tracker] Post #' + postNum + ' - Marker fallback inserted before comment boundary'); - return true; - } - postElement.appendChild(marker); setTrackerInsertionMarkerLocked(marker, false); console.log('[FB Tracker] Post #' + postNum + ' - Marker fallback appended to post'); @@ -661,12 +663,7 @@ function isTrackerInsertionMarkerPlacementValid(postElement, marker, buttonBar) return false; } - const actionAnchor = getDirectActionAnchorInPost(postElement, buttonBar); - const commentBoundary = findCommentBoundaryAnchorInPost(postElement, actionAnchor); - - if (actionAnchor && isNodeAfter(actionAnchor, marker)) { - return false; - } + const commentBoundary = findCommentBoundaryAnchorInPost(postElement); if (commentBoundary && isNodeAfter(marker, commentBoundary)) { return false;