Skip to content

Commit

Permalink
Count (cookie)blocked domains only on options page
Browse files Browse the repository at this point in the history
  • Loading branch information
ghostwords committed Oct 1, 2020
1 parent 29150cd commit 926f777
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions src/_locales/en_US/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -468,8 +468,8 @@
"description": "Intro page paragraph."
},
"options_domain_list_trackers": {
"message": "Privacy Badger has detected $COUNT$ potential $TRACKER_LINK_START$tracking domains$TRACKER_LINK_END$ so far.",
"description": "Message under the Tracking Domains tab on the options page. Shown after Privacy Badger learned about more than one tracker.",
"message": "Privacy Badger has decided to block $COUNT$ potential $TRACKER_LINK_START$tracking domains$TRACKER_LINK_END$ so far",
"description": "Shown on the Tracking Domains tab on the options page after Privacy Badger learned to block one or more domains",
"placeholders": {
"count": {
"content": "$1",
Expand All @@ -486,7 +486,7 @@
},
"options_domain_list_no_trackers": {
"message": "Privacy Badger hasn't detected any <a target='_blank' tabindex=-1 title='i18n_what_is_a_tracker' class='tooltip' href='https://www.eff.org/privacybadger#faq-What-is-a-third-party-tracker?'>tracking domains</a> yet. Keep browsing!",
"description": "Shown on the Tracking Domains tab on the options page for new and recent installations."
"description": "Shown on the Tracking Domains tab on the options page if all tracking domains have been removed."
},
"name": {
"message": "Privacy Badger",
Expand Down
12 changes: 6 additions & 6 deletions src/js/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -592,11 +592,10 @@ function revertDomainControl(event) {
* Displays list of all tracking domains along with toggle controls.
*/
function updateSummary() {
// Check to see if any tracking domains have been found before continuing.
let allTrackingDomains = getOriginsArray(OPTIONS_DATA.origins, null, null, null, true);

// if there are no tracking domains
let allTrackingDomains = Object.keys(OPTIONS_DATA.origins);
if (!allTrackingDomains || !allTrackingDomains.length) {
// leave out number of trackers and slider instructions message if no sliders will be displayed
// hide the number of trackers and slider instructions message
$("#options_domain_list_trackers").hide();

// show "no trackers" message
Expand All @@ -614,8 +613,9 @@ function updateSummary() {
$("#options_domain_list_no_trackers").hide();
$("#tracking-domains-div").show();

// count unique (blocked and not-yet-blocked) tracking base domains
let baseDomains = new Set(allTrackingDomains.map(d => window.getBaseDomain(d)));
// count unique (cookie)blocked tracking base domains
let blockedDomains = getOriginsArray(OPTIONS_DATA.origins, null, null, null, false);
let baseDomains = new Set(blockedDomains.map(d => window.getBaseDomain(d)));
$("#options_domain_list_trackers").html(i18n.getMessage(
"options_domain_list_trackers", [
baseDomains.size,
Expand Down
4 changes: 2 additions & 2 deletions tests/selenium/options_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def test_added_multiple_origins_display(self):
# check tracker count
self.assertEqual(
self.driver.find_element_by_id("options_domain_list_trackers").text,
"Privacy Badger has detected 2 potential tracking domains so far.",
"Privacy Badger has decided to block 2 potential tracking domains so far",
"Origin tracker count should be 2 after adding origin"
)

Expand Down Expand Up @@ -229,7 +229,7 @@ def test_reset_data(self):
# make sure only two trackers are displayed now
self.assertEqual(
self.driver.find_element_by_id("options_domain_list_trackers").text,
"Privacy Badger has detected 2 potential tracking domains so far.",
"Privacy Badger has decided to block 2 potential tracking domains so far",
"Origin tracker count should be 2 after clearing and adding origins"
)

Expand Down

0 comments on commit 926f777

Please sign in to comment.