Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Custom Sites to the Facebook Container #566

Merged
merged 12 commits into from
Feb 13, 2020
Merged

Conversation

maxxcrawford
Copy link
Collaborator

@maxxcrawford maxxcrawford commented Dec 31, 2019

This PR adds buttons to the doorhanger panel for users to add/remove the active page/domain to the Facebook container.

Fixes #422
Fixes #550

PR To-do List

  • Update onboarding panel copy/images
  • Add tooltip text
  • Fix issue where "Add this site" shows up on default FB URLs (from FACEBOOK_DOMAINS)
  • Add test directions to this PR

Testing Steps

Use the following directions to verify this PR works as is.

  1. Run the add-on. (This will open up the add-on in a temporary new browser)
$ web-ext run -s src/ 
  1. Go to the following sites:
  1. Once on the site, verify that trackers are detected as expected.

  2. Click on the Facebook Container add-on icon within the browser chrome to trigger the panel: image

  3. Attempt to add that site to the Facebook Container:

  • Non-Facebook tracking site and Facebook tracking site should be able be to added by clicking the following button:
    image

Once this button is clicked, the expected action is for the tab to close and reopen the same URL INSIDE the Facebook Container.

  1. Once added, attempt to remove the newly added site from the Facebook Container:
  • Confirm you're in the Facebook Container
    image

  • Click on the Facebook Container add-on icon within the browser chrome to trigger the panel:
    image

    • On default Facebook Container sites (like Facebook.com and Instagram.com), these sites cannot be removed.
    • On non-default sites, it should close and reload the page OUTSIDE of the Facebook Container.

Screenshots

No trackers detected panel (outside of FB Container):
image

Trackers detected panel (outside of FB Container):
image

Custom site added to FB Container
image

On default Facebook domain:
image

On default Facebook domain (hover tooltip):
image

In-page UI Panel (Revised Copy + Image):
image

New Panel for Adding Custom Site:
image

Comment on lines +193 to +195
position: absolute;
left: 1rem;
bottom: 2em;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this differs from the InVision mockup as the panel has overflow:hidden on it, not allowing for the tooltip to be visible outside of its' parent container.

InVision mockup:
image

cc/ @e-pang

…w UI for adding sites to the FB Container. This includes removing the previous strings (Panel 3)
@maxxcrawford
Copy link
Collaborator Author

@e-pang Note that I updated the CSS to bold the first sentence in each panel, per the InVision mockups:

image

@ddurst
Copy link

ddurst commented Jan 3, 2020

I'm struggling with the strings in this a bit, but maybe it's just me.

When we talk about "sites allowed in FBC," it sounds to me like we're putting other things in that container. Phrased like that, it sounds like we're just lumping sites together, or putting things in the same container. Maybe this is a technical detail (maybe it's not), but for the user, the potential ramifications aren't clearly communicated.

To me, "sites allowed" means that Facebook can access your data (I'm deliberately oversimplifying) -- if we're trying to make it clear that FB is contained/isolated, what "allowing" a site means to me is that the user is allowing FB to potentially access your data through/on any site you "allow."

I'd expect this to be more like "Don't block Facebook trackers on these sites" or something like that -- not to sound too opinionated, but not to softball it either.

@ddurst
Copy link

ddurst commented Jan 3, 2020

(I don't know that we can change this, but in the future perhaps we could/should.)

@maxxcrawford maxxcrawford marked this pull request as ready for review January 3, 2020 21:12
@maxxcrawford maxxcrawford requested a review from flodolo as a code owner January 3, 2020 21:12
src/_locales/en/messages.json Outdated Show resolved Hide resolved
Copy link

@kendallcorner kendallcorner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty good

src/panel.js Show resolved Hide resolved
src/panel.js Show resolved Hide resolved
src/panel.js Show resolved Hide resolved
src/panel.js Show resolved Hide resolved
@kendallcorner
Copy link

Also, we've already discussed a little that this has potential to conflict with MAC.

When I have a site assigned in MAC, and then try to add it to fbc, it doesn't take. It just keeps getting opened in my MAC container. I believe we can use the messaging already setup (sendJailedDomainsToMAC()) to send these new sites to MAC as well.

Copy link
Member

@groovecoder groovecoder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all nits except 2 of my comments.

src/panel.js Outdated
}

const addedSitesList = await browser.runtime.sendMessage("what-sites-are-added");
const hostname = await getActiveHostname();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: const activeTabHostname = await getActiveTabHostname();

src/panel.js Outdated

if (addedSitesList.includes(hostname)) {
return true;
} else {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: drop the else - return true will exit the function so the else block is not needed. I trim a lot of else blocks out of my code just for readability.


if (panelId === "no-trackers") {
await addCustomSiteButton(fragment, panelId);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is called below on line 369 whether or not panelId === "no-trackers" - so do we need this if block?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes – It's a quirk for how its' rendered in the panel. I tried different combinations/ordering of these.

@@ -116,6 +149,37 @@ const addLearnHowFBCWorksButton = async (fragment) => {
addSpan(button, "sites-added-subhead");
};

const addCustomSiteButton = async (fragment, panelId) => {
const shouldShowRemoveSiteButton = await isSiteInContainer(panelId);
let button;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't return this value from the function, so we can probably drop it?

 const addCustomSiteButton = async (fragment, panelId) => {
   const shouldShowRemoveSiteButton = await isSiteInContainer(panelId);
   if (shouldShowRemoveSiteButton) {
     addFullWidthButton(fragment, "remove-site-from-container");
     addSpan(button, "button-remove-site");
     addTooltip(button, "button-remove-site-tooltip");
     return;
   }
   addFullWidthButton(fragment, "add-site-to-container");
   addSpan(button, "button-allow-site");
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The button is passed as an argument in both the addSpan and addTooltip functions. I think we need to keep it.

src/panel.js Outdated

if (shouldShowRemoveSiteButton) {
const removeSiteFromContainerLink = document.querySelector(".remove-site-from-container");
removeSiteFromContainerLink.addEventListener("click", async () => removeSiteFromContainer());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: can remove the else block here with a return; early statement, like in the above if (panelId === "on-facebook") { block.

src/panel.js Outdated
if (res === 4) {
// This accounts for the skipped Panel #3
buildOnboardingPanel(2);
} else {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: remove else block with an early return;

src/panel.js Outdated
@@ -256,7 +325,7 @@ document.addEventListener("DOMContentLoaded", async () => {

const onboarding = (currentPanel.includes("onboarding"));
if (!onboarding) {
return buildPanel(currentPanel);
return await buildPanel(currentPanel);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated variable names to provide more context
Resolved "return await"  issue
Consolidated buildPanel function if statements
@maxxcrawford maxxcrawford requested review from groovecoder, kendallcorner and flodolo and removed request for lesleyjanenorton February 13, 2020 16:10
Copy link
Member

@groovecoder groovecoder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm ... I don't think this bug is related to the PR - it happens on master too - but the badge shows a warning in duckduckgo.com now?

image

It looks like blockFacebookSubResources only ever sets trackersDetected: true? I.e., it doesn't "reset" trackersDetected: false? So as soon as a tab gets marked with trackersDetected: true the browserAction icon badge is stuck in that state?

The fix seems to be to add a trackersDetected: false line inside the requestDetails.type === "main_frame" block of blackFacebookSubResources ...

    if (requestDetails.type === "main_frame") {
+     tabStates[requestDetails.tabId] = { trackersDetected: false };
      return {};
    }

Can be fixed in a separate PR?

@groovecoder groovecoder merged commit 5742261 into master Feb 13, 2020
@groovecoder groovecoder deleted the 422-add-custom-sites branch February 13, 2020 21:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add prefereneces/options page In-content panel enabling users to "allow FB to track me on this site"
5 participants