From 88a3379fe75f3f1888d69170cfdcfcb63a87d4d1 Mon Sep 17 00:00:00 2001 From: Marcus Date: Wed, 11 Sep 2024 13:10:44 -0700 Subject: [PATCH] implement observer --- src/features/tweaks/hide_following_notification_badge.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/features/tweaks/hide_following_notification_badge.js b/src/features/tweaks/hide_following_notification_badge.js index 673115a65..ac47759c2 100644 --- a/src/features/tweaks/hide_following_notification_badge.js +++ b/src/features/tweaks/hide_following_notification_badge.js @@ -15,10 +15,14 @@ export const styleElement = buildStyle(` } `); -const onTitleChanged = ([titleElement]) => { +const onTitleChanged = () => { + const titleElement = document.querySelector('head title:not([data-xkit])'); + const rawTitle = titleElement.textContent; const newTitle = rawTitle.replace(/^\(\d{1,2}\) /, ''); customTitleElement.textContent = newTitle; + + new MutationObserver(onTitleChanged).observe(titleElement, { characterData: true, subtree: true }); }; export const main = async () => {