Skip to content
This repository has been archived by the owner on Nov 21, 2022. It is now read-only.

#decouple content script #96

Conversation

ribicn-softerrific
Copy link
Collaborator

@ribicn-softerrific ribicn-softerrific commented Feb 17, 2020

decoupled script, merged previous changes, updated observers and selectors

  • decoupled content script to separate functions
  • started purifying functions from side effects
  • merged pull request Use Fetch API for communication with backend #95 from river-honer/fetch-api into #decouple_content_script
  • fixed merge conflicts
  • fixed minor glitches found during testing
  • debugged issue which was causing bad request on certain tweets
  • updated checkText with better error logging
  • added new Observer which watches as tweetList is added to root
  • modified existing checkTweetListObserver to watch over tweetList and not root in order to further specify it
  • moved selectors to constants and added comments for opt-out-ext.js

@ribicn-softerrific ribicn-softerrific marked this pull request as ready for review February 18, 2020 15:31
@ribicn-softerrific ribicn-softerrific changed the title [WIP] #decouple content script #decouple content script Feb 18, 2020
@ribicn-softerrific ribicn-softerrific merged commit 0f6fa95 into opt-out-tools:master Feb 21, 2020
@ribicn-softerrific ribicn-softerrific deleted the #decouple_contentScript branch February 21, 2020 09:59
cmcaine added a commit to cmcaine/ignore that referenced this pull request Feb 25, 2020
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) {
Copy link
Contributor

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;
Copy link
Contributor

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(
Copy link
Contributor

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.

Copy link
Contributor

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.

malteserteresa pushed a commit that referenced this pull request Feb 26, 2020
Fix: PR #96 removed our observer overly eagerly
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants