-
-
Notifications
You must be signed in to change notification settings - Fork 13
#decouple content script #96
#decouple content script #96
Conversation
- modified existing checkTweetListObserver to watch over tweetList and not root in order to further specify it
Twitter is served as a SPA, so it is not safe to remove our root observer after finding the first tweet list element. When the user browses to a new page the tweet list element on page 1 may not be the same as the element on page 2. I've restored the old listener from pre-opt-out-tools#96 with small changes to accommodate the new API.
option = message.selector; | ||
slider = message.slider; | ||
browser.runtime.onMessage.addListener((popupSettings) => { | ||
if (popupPrefs !== popupSettings) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these objects will always have different identities, even if their content is the same.
}; | ||
const bodyColor = window.getComputedStyle(document.body, null).getPropertyValue('background-color'); | ||
const root = document.getElementById(SELECTOR_OFFLINE_ROOT) || document.getElementById(SELECTOR_ONLINE_ROOT); | ||
const tweetSelector = (document.querySelector('body').classList.contains('logged-out')) ? SELECTOR_OFFLINE_TWEET : SELECTOR_ONLINE_TWEET; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't these be in CAPS?
}); | ||
} else { | ||
console.log('Failed response: ', response); | ||
const checkTweetListCreation = new MutationObserver( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Twitter is served as a SPA, so this is not safe: the tweet list element on page 1 may not be the same as the element on page 2, but we'll have already removed our observer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've fixed this in pr #100.
Fix: PR #96 removed our observer overly eagerly
decoupled script, merged previous changes, updated observers and selectors