-
Notifications
You must be signed in to change notification settings - Fork 176
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
Conversation
…ncluding helper functions to determine which site user is on, and if that site is in the FBC
…cluding event listener(s) for the button
…n default FB domain URLs
position: absolute; | ||
left: 1rem; | ||
bottom: 2em; |
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.
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.
cc/ @e-pang
…w UI for adding sites to the FB Container. This includes removing the previous strings (Panel 3)
…age from the directory.
@e-pang Note that I updated the CSS to bold the first sentence in each panel, per the InVision mockups: |
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. |
(I don't know that we can change this, but in the future perhaps we could/should.) |
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.
Looks pretty good
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 ( |
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.
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(); |
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.
nit: const activeTabHostname = await getActiveTabHostname();
src/panel.js
Outdated
|
||
if (addedSitesList.includes(hostname)) { | ||
return true; | ||
} else { |
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.
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); | ||
} |
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.
This is called below on line 369 whether or not panelId === "no-trackers"
- so do we need this if block?
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.
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; |
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.
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");
}
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.
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()); |
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.
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 { |
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.
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); |
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.
Updated variable names to provide more context Resolved "return await" issue Consolidated buildPanel function if statements
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.
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?
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?
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
Testing Steps
Use the following directions to verify this PR works as is.
Once on the site, verify that trackers are detected as expected.
Click on the Facebook Container add-on icon within the browser chrome to trigger the panel:
Attempt to add that site to the Facebook Container:
Once this button is clicked, the expected action is for the tab to close and reopen the same URL INSIDE the Facebook Container.
Confirm you're in the Facebook Container
Click on the Facebook Container add-on icon within the browser chrome to trigger the panel:
Screenshots
No trackers detected panel (outside of FB Container):
Trackers detected panel (outside of FB Container):
Custom site added to FB Container
On default Facebook domain:
On default Facebook domain (hover tooltip):
In-page UI Panel (Revised Copy + Image):
New Panel for Adding Custom Site: