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

Hide sliders by default #2744

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/_locales/en_US/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,14 @@
"message": "There are no third party resources on this page. Hooray for privacy!",
"description": "Text shown in the popup when showing non-tracking domains is enabled, and there are no third-party domains on the page."
},
"popup_show_more": {
"message": "Show more",
"description": "Instructions to click to expand the blocked resources container on the popup"
},
"popup_show_less": {
"message": "Show less",
"description": "Instructions to click to collapse the blocked resources container on the popup"
},
"intro_by_eff": {
"message": "A project of the Electronic Frontier Foundation",
"description": ""
Expand Down
1 change: 1 addition & 0 deletions src/js/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -815,6 +815,7 @@ Badger.prototype = {
seenComic: false,
sendDNTSignal: true,
showCounter: true,
showExpandedTrackingSection: false,
showIntroPage: true,
showNonTrackingDomains: false,
showTrackingDomains: false,
Expand Down
40 changes: 39 additions & 1 deletion src/js/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,19 @@ function init() {
$('#blockedResourcesContainer').on('change', 'input:radio', updateOrigin);
$('#blockedResourcesContainer').on('click', '.userset .honeybadgerPowered', revertDomainControl);

$('#expand-blocked-resources-text').on('click', showBlockedResourcesHandler);
$('#collapse-blocked-resources-text').on('click', hideBlockedResourcesHandler);

if (POPUP_DATA.showExpandedTrackingSection) {
$('#expand-blocked-resources-text').hide();
$('#collapse-blocked-resources-text').show();
$('#blockedResources').show();
} else if (!POPUP_DATA.showExpandedTrackingSection) {
$('#expand-blocked-resources-text').show();
$('#collapse-blocked-resources-text').hide();
$('#blockedResources').hide();
}

$("#version").text(
chrome.i18n.getMessage("version", chrome.runtime.getManifest().version)
);
Expand Down Expand Up @@ -452,6 +465,30 @@ function revertDomainControl(event) {
});
}

/**
* Click handler for expanding the blocked resources section
*/
function showBlockedResourcesHandler() {
$("#collapse-blocked-resources-text").show();
$("#expand-blocked-resources-text").hide();
$("#blockedResources").show();
chrome.runtime.sendMessage({
type: "showTrackingDomainsSection"
});
}

/**
* Click handler for hiding the blocked resources section
*/
function hideBlockedResourcesHandler() {
$("#collapse-blocked-resources-text").hide();
$("#expand-blocked-resources-text").show();
$("#blockedResources").hide();
chrome.runtime.sendMessage({
type: "hideTrackingDomainsSection"
});
}

/**
* Refresh the content of the popup window
*
Expand Down Expand Up @@ -506,9 +543,10 @@ function refreshPopup() {
}

if (!originsArr.length) {
// hide the number of trackers and slider instructions message
// hide the number of trackers, slider instructions messages
// if no sliders will be displayed
$("#instructions-many-trackers").hide();
$("#toggleBlockedResourcesContainer").hide();

// show "no trackers" message
$("#instructions-no-trackers").show();
Expand Down
13 changes: 13 additions & 0 deletions src/js/webrequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -1039,6 +1039,7 @@ function dispatcher(request, sender, sendResponse) {
noTabData: false,
origins,
seenComic: badger.getSettings().getItem("seenComic"),
showExpandedTrackingSection: badger.getSettings().getItem("showExpandedTrackingSection"),
showLearningPrompt: badger.getPrivateSettings().getItem("showLearningPrompt"),
showNonTrackingDomains: badger.getSettings().getItem("showNonTrackingDomains"),
tabHost: tab_host,
Expand Down Expand Up @@ -1126,6 +1127,18 @@ function dispatcher(request, sender, sendResponse) {
break;
}

case "showTrackingDomainsSection": {
badger.getSettings().setItem("showExpandedTrackingSection", true);
sendResponse();
break;
}

case "hideTrackingDomainsSection": {
badger.getSettings().setItem("showExpandedTrackingSection", false);
sendResponse();
break;
}

case "downloadCloud": {
chrome.storage.sync.get("disabledSites", function (store) {
if (chrome.runtime.lastError) {
Expand Down
4 changes: 4 additions & 0 deletions src/skin/popup.css
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,10 @@ font-size: 16px;
min-height: 70px;
}

#toggleBlockedResourcesContainer {
text-align: center;
}

#intro-reminder-btn, #critical-error-link, #learning-prompt-btn {
background-color: #ff641c;
border: 2px solid #ff641c;
Expand Down
4 changes: 4 additions & 0 deletions src/skin/popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ <h2 id="title-name"><span class="i18n_name"></span></h2>
<span class="i18n_popup_instructions_no_trackers" data-i18n_contents_placeholders="<a target='_blank' title='i18n_what_is_a_tracker' class='tooltip' href='https://privacybadger.org/#What-is-a-third-party-tracker'>"></span>
<span id="no-third-parties" class="i18n_popup_blocked" style="display:none"></span>
</span>
<div id="toggleBlockedResourcesContainer">
<span id="expand-blocked-resources-text" class="i18n_popup_show_more"><span class="ui-icon ui-icon-caret-d"></span></span>
<span id="collapse-blocked-resources-text" class="i18n_popup_show_less" style="display:none"><span class="ui-icon ui-icon-caret-u"></span></span>
</div>
</p>
<div class="spacer"></div>
<div id="blockedResources"></div>
Expand Down
3 changes: 3 additions & 0 deletions tests/selenium/popup_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,9 @@ def test_reverting_control(self):

self.open_popup(origins={DOMAIN:"cookieblock"})

# make sure the 'see more' blocked resources container is expanded
self.driver.find_element_by_id("expand-blocked-resources-text").click()

# set the domain to user control
# click input with JavaScript to avoid "Element ... is not clickable" /
# "Other element would receive the click" Selenium limitation
Expand Down