From 71fd1aafbf033bdb2fc13cac6f2f96eb7fee7df1 Mon Sep 17 00:00:00 2001 From: Christopher Tino Date: Fri, 17 Apr 2020 16:06:00 -0400 Subject: [PATCH 1/4] add new component to Settings panel for Ad Blocker settings --- CHANGELOG.md | 1 + _locales/en/messages.json | 15 +++++ app/panel/components/Settings.jsx | 4 ++ app/panel/components/Settings/AdBlocker.jsx | 65 +++++++++++++++++++ .../components/Settings/SettingsMenu.jsx | 11 ++++ src/background.js | 7 +- src/classes/ConfData.js | 1 + src/classes/Globals.js | 1 + src/classes/PanelData.js | 3 +- 9 files changed, 105 insertions(+), 3 deletions(-) create mode 100644 app/panel/components/Settings/AdBlocker.jsx diff --git a/CHANGELOG.md b/CHANGELOG.md index 745c96af6..8e0e61c36 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ### GHOSTERY 8.5.0 () + New Spring themes for Plus subscribers (#525) ++ New settings option to select Ad-Blocker lists (#) + Add password reset link to Intro Hub (#507) + Updated in-app promo modals (#509) + Fixes bug in site-specific tracker white-listing (#522, Fixes #519) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 3eee43116..7c23561e6 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -806,6 +806,21 @@ "description": "Options page site whitelisting error message shown when whitelisting a URL that is already in the whitelist.", "message": "This site is already whitelisted." }, + "settings_adblocker": { + "message": "Ad Blocker" + }, + "settings_adblocker_lists": { + "message": "Select which Ad Blocking filter lists will be loaded." + }, + "settings_adblocker_list_1": { + "message": "Ads only" + }, + "settings_adblocker_list_2": { + "message": "Ads + Trackers" + }, + "settings_adblocker_list_3": { + "message": "Ads + Trackers + Annoyances" + }, "settings_purple_box": { "message": "Purple Box" }, diff --git a/app/panel/components/Settings.jsx b/app/panel/components/Settings.jsx index 48884d790..52f528caa 100644 --- a/app/panel/components/Settings.jsx +++ b/app/panel/components/Settings.jsx @@ -17,6 +17,7 @@ import { Route } from 'react-router-dom'; import { sendMessage } from '../utils/msg'; import SettingsMenu from './Settings/SettingsMenu'; import GlobalBlocking from './Settings/GlobalBlocking'; +import AdBlocker from './Settings/AdBlocker'; import TrustAndRestrict from './Settings/TrustAndRestrict'; import GeneralSettings from './Settings/GeneralSettings'; import Notifications from './Settings/Notifications'; @@ -79,6 +80,8 @@ class Settings extends React.Component { GeneralSettingsComponent = () => (); + AdBlockerComponent = () => (); + PurpleboxComponent = () => (); NotificationsComponent = () => (); @@ -165,6 +168,7 @@ class Settings extends React.Component { + diff --git a/app/panel/components/Settings/AdBlocker.jsx b/app/panel/components/Settings/AdBlocker.jsx new file mode 100644 index 000000000..90e44a6c4 --- /dev/null +++ b/app/panel/components/Settings/AdBlocker.jsx @@ -0,0 +1,65 @@ +/** + * Ad Blocker Settings Component + * + * Ghostery Browser Extension + * https://www.ghostery.com/ + * + * Copyright 2019 Ghostery, Inc. All rights reserved. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0 + */ + +import React from 'react'; +import PropTypes from 'prop-types'; +import { RadioButtonGroup } from '../BuildingBlocks'; + +/** + * @class Implement Ad Blocker Settings subview as a React component. + * The view opens from the left-side menu of the main Settings view. + * It allows the user to choose their Ad Blocker filter lists. + * @memberOf SettingsComponents + */ +const AdBlocker = (props) => { + const { settingsData } = props; + + const handleListSelection = (index) => { + props.actions.selectItem({ + event: 'cliqz_adb_mode', + value: index, + }); + }; + + return ( +
+
+
+

{ t('settings_adblocker') }

+
{ t('settings_adblocker_lists') }
+ +
+
+
+ ); +}; + +AdBlocker.propTypes = { + settingsData: PropTypes.shape({ + cliqz_adb_mode: PropTypes.number, + }), + actions: PropTypes.shape({ + selectItem: PropTypes.func.isRequired, + }).isRequired, +}; +AdBlocker.defaultProps = { + settingsData: { + cliqz_adb_mode: 0, + }, +}; + +export default AdBlocker; diff --git a/app/panel/components/Settings/SettingsMenu.jsx b/app/panel/components/Settings/SettingsMenu.jsx index 80966c193..1e72e7d13 100644 --- a/app/panel/components/Settings/SettingsMenu.jsx +++ b/app/panel/components/Settings/SettingsMenu.jsx @@ -14,6 +14,10 @@ import React from 'react'; import { NavLink } from 'react-router-dom'; import ClassNames from 'classnames'; +import globals from '../../../../src/classes/Globals'; + +const IS_CLIQZ = (globals.BROWSER_INFO.name === 'cliqz'); + /** * @const Implement left pane of the main Settings view as a * menu which allows to navigate to Setting subviews. @@ -41,6 +45,13 @@ const SettingsMenu = (props) => { { t('settings_general_settings') } + {!IS_CLIQZ && ( +
  • + + { t('settings_adblocker') } + +
  • + )}
  • { t('settings_notifications') } diff --git a/src/background.js b/src/background.js index 12d0d5e31..c4f579689 100644 --- a/src/background.js +++ b/src/background.js @@ -1052,11 +1052,14 @@ function initializeDispatcher() { setCliqzModuleEnabled(adblocker, false); } }); - + dispatcher.on('conf.save.cliqz_adb_mode', (val) => { + if (!IS_CLIQZ) { + cliqz.prefs.set('cliqz-adb-mode', val); + } + }); dispatcher.on('conf.changed.settings', debounce((key) => { log('Conf value changed for a watched user setting:', key); }, 200)); - dispatcher.on('globals.save.paused_blocking', () => { // if user has paused Ghostery, suspect broken page if (globals.SESSION.paused_blocking) { metrics.handleBrokenPageTrigger(globals.BROKEN_PAGE_PAUSE); } diff --git a/src/classes/ConfData.js b/src/classes/ConfData.js index 09b38f48d..cd62556e2 100644 --- a/src/classes/ConfData.js +++ b/src/classes/ConfData.js @@ -100,6 +100,7 @@ class ConfData { _initProperty('block_by_default', false); _initProperty('bugs_last_checked', 0); _initProperty('bugs_last_updated', nowTime); + _initProperty('cliqz_adb_mode', 0); _initProperty('cliqz_legacy_opt_in', false); _initProperty('cliqz_import_state', 0); _initProperty('cmp_version', 0); diff --git a/src/classes/Globals.js b/src/classes/Globals.js index c1d3c27d4..cd56ccdb1 100644 --- a/src/classes/Globals.js +++ b/src/classes/Globals.js @@ -101,6 +101,7 @@ class Globals { 'alert_bubble_timeout', 'alert_expanded', 'block_by_default', + 'cliqz_adb_mode', 'cliqz_module_whitelist', 'current_theme', 'enable_ad_block', diff --git a/src/classes/PanelData.js b/src/classes/PanelData.js index 96b07c2a7..281433511 100644 --- a/src/classes/PanelData.js +++ b/src/classes/PanelData.js @@ -481,7 +481,7 @@ class PanelData { */ _getUserSettingsForSettingsView(userSettingsSource) { const { - alert_bubble_pos, alert_bubble_timeout, block_by_default, enable_autoupdate, + alert_bubble_pos, alert_bubble_timeout, block_by_default, cliqz_adb_mode, enable_autoupdate, enable_click2play, enable_click2play_social, enable_human_web, enable_offers, enable_metrics, hide_alert_trusted, ignore_first_party, notify_library_updates, notify_promotions, notify_upgrade_updates, selected_app_ids, show_alert, show_badge, @@ -492,6 +492,7 @@ class PanelData { alert_bubble_pos, alert_bubble_timeout, block_by_default, + cliqz_adb_mode, enable_autoupdate, enable_click2play, enable_click2play_social, From 37fd0773773cad14a6af705a8a3357c0fdbca2da Mon Sep 17 00:00:00 2001 From: Christopher Tino Date: Mon, 20 Apr 2020 15:47:00 -0400 Subject: [PATCH 2/4] proper access to IS_CLIQZ global --- CHANGELOG.md | 2 +- app/panel/components/Rewards.jsx | 2 +- app/panel/components/Settings/OptIn.jsx | 2 +- app/panel/components/Settings/SettingsMenu.jsx | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e0e61c36..3d5589ff0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ ### GHOSTERY 8.5.0 () + New Spring themes for Plus subscribers (#525) -+ New settings option to select Ad-Blocker lists (#) ++ New settings option to select Ad-Blocker lists (#527) + Add password reset link to Intro Hub (#507) + Updated in-app promo modals (#509) + Fixes bug in site-specific tracker white-listing (#522, Fixes #519) diff --git a/app/panel/components/Rewards.jsx b/app/panel/components/Rewards.jsx index 2c628882a..c707a84d1 100644 --- a/app/panel/components/Rewards.jsx +++ b/app/panel/components/Rewards.jsx @@ -20,7 +20,7 @@ import { sendMessage } from '../utils/msg'; import globals from '../../../src/classes/Globals'; import { log } from '../../../src/utils/common'; -const IS_CLIQZ = (globals.BROWSER_INFO.name === 'cliqz'); +const { IS_CLIQZ } = globals; /** * @class The Rewards Panel shows offers generated by Ghostery Rewards. diff --git a/app/panel/components/Settings/OptIn.jsx b/app/panel/components/Settings/OptIn.jsx index a2da92c2e..04598f99f 100644 --- a/app/panel/components/Settings/OptIn.jsx +++ b/app/panel/components/Settings/OptIn.jsx @@ -14,7 +14,7 @@ import React from 'react'; import globals from '../../../../src/classes/Globals'; -const IS_CLIQZ = (globals.BROWSER_INFO.name === 'cliqz'); +const { IS_CLIQZ } = globals; /** * @class Implement Opt In subview as a React component. diff --git a/app/panel/components/Settings/SettingsMenu.jsx b/app/panel/components/Settings/SettingsMenu.jsx index 1e72e7d13..f0264b4c2 100644 --- a/app/panel/components/Settings/SettingsMenu.jsx +++ b/app/panel/components/Settings/SettingsMenu.jsx @@ -16,7 +16,7 @@ import { NavLink } from 'react-router-dom'; import ClassNames from 'classnames'; import globals from '../../../../src/classes/Globals'; -const IS_CLIQZ = (globals.BROWSER_INFO.name === 'cliqz'); +const { IS_CLIQZ } = globals; /** * @const Implement left pane of the main Settings view as a From cf8ead48fbc03b330856a5a318a8d5840bed2592 Mon Sep 17 00:00:00 2001 From: Christopher Tino Date: Mon, 20 Apr 2020 16:32:51 -0400 Subject: [PATCH 3/4] update copy --- _locales/en/messages.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 7c23561e6..325951447 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -807,10 +807,10 @@ "message": "This site is already whitelisted." }, "settings_adblocker": { - "message": "Ad Blocker" + "message": "Ad Block Lists" }, "settings_adblocker_lists": { - "message": "Select which Ad Blocking filter lists will be loaded." + "message": "Load the following Ad Block filter lists:" }, "settings_adblocker_list_1": { "message": "Ads only" From b7c3f922969e92ac1ae68935a3a56222ebbcd3a5 Mon Sep 17 00:00:00 2001 From: Christopher Tino Date: Tue, 21 Apr 2020 09:06:26 -0400 Subject: [PATCH 4/4] update browser core --- package.json | 2 +- yarn.lock | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 369adca6d..78326a781 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "dependencies": { "@cliqz/adblocker-circumvention": "^1.12.2", "@cliqz/url-parser": "^1.1.3", - "browser-core": "https://github.com/cliqz-oss/browser-core/releases/download/7.45.0/browser-core-7.45.0.tgz", + "browser-core": "https://github.com/cliqz-oss/browser-core/releases/download/v7.45.2/browser-core-7.45.2.tgz", "classnames": "^2.2.5", "d3": "^5.15.1", "foundation-sites": "^6.6.2", diff --git a/yarn.lock b/yarn.lock index 83b80ea8b..3f0b42416 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1642,9 +1642,9 @@ brorand@^1.0.1: resolved "https://registry.yarnpkg.com/brorand/-/brorand-1.1.0.tgz#12c25efe40a45e3c323eb8675a0a0ce57b22371f" integrity sha1-EsJe/kCkXjwyPrhnWgoM5XsiNx8= -"browser-core@https://github.com/cliqz-oss/browser-core/releases/download/7.45.0/browser-core-7.45.0.tgz": - version "7.45.0" - resolved "https://github.com/cliqz-oss/browser-core/releases/download/7.45.0/browser-core-7.45.0.tgz#bcd95e54f5992912f2e971ddabb607ba612c588d" +"browser-core@https://github.com/cliqz-oss/browser-core/releases/download/v7.45.2/browser-core-7.45.2.tgz": + version "7.45.2" + resolved "https://github.com/cliqz-oss/browser-core/releases/download/v7.45.2/browser-core-7.45.2.tgz#548ff63f47ac7a92be2ffc2bb8edc6de84db7d73" dependencies: "@cliqz-oss/dexie" "^2.0.4" "@cliqz/adblocker-webextension" "^1.9.2"