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

GH-1798: Update Unknown category to include Ad Blocker unknowns #433

Merged
merged 10 commits into from Aug 2, 2019

Combine Ad Blocking unknown trackers with Anti-Tracking into one Unkn…

…own category in the tracker list
  • Loading branch information
Eden12345 committed Aug 1, 2019
commit b5d7668290c16ef66db5b86090e25668d8fd3712
@@ -1,11 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="25" height="25">
<g fill="none" fill-rule="evenodd">
<g transform="translate(1 1)">
<circle cx="11.865" cy="11.865" r="11.865" fill="#8459A5" stroke="#00AEF0" stroke-width=".5"/>
<path fill="#D2D2CC" d="M18.48 11.748L15.36 8.64l3.116 3.103.005.005"/>
<path fill="#4D4D4B" d="M7.2 14.282l.363-.362-.363.362"/>
<path fill="#64849B" d="M7.326 14.408l-.126-.126.363-.362.126.126-.363.362"/>
</g>
<path fill="#FFFFFE" stroke="#1DAFED" stroke-width="1.6" d="M13.149 6.022a.505.505 0 0 0-.298 0l-6.404 1.7A.574.574 0 0 0 6 8.286c.03 4.56 2.472 8.792 6.672 11.624.09.06.209.089.328.089.12 0 .238-.03.328-.09 4.2-2.83 6.642-7.063 6.672-11.623a.574.574 0 0 0-.447-.566L13.15 6.022z"/>
</g>
</svg>
<svg xmlns="http://www.w3.org/2000/svg" width="25" height="25"><g fill="none" transform="translate(1 1)"><circle cx="11.865" cy="11.865" r="11.865" fill="#8459A5" stroke="#86449B" stroke-width=".5"/><path fill="#86449B" d="M17.152 6.847a1.994 1.994 0 0 0-1.462-.607h-6.9c-.57 0-1.058.203-1.463.607A1.995 1.995 0 0 0 6.72 8.31v6.9c0 .57.203 1.058.607 1.463.405.404.893.607 1.463.607h6.9c.57 0 1.058-.203 1.462-.607.405-.405.608-.893.608-1.463v-6.9c0-.57-.203-1.058-.608-1.463zm-5.86 5.991a1.469 1.469 0 0 1-1.079.446 1.469 1.469 0 0 1-1.078-.446 1.469 1.469 0 0 1-.446-1.078c0-.422.15-.781.446-1.078a1.469 1.469 0 0 1 1.078-.446c.422 0 .78.149 1.078.446.291.282.453.672.446 1.078.007.406-.155.796-.446 1.078zm4.053 0a1.468 1.468 0 0 1-1.078.446 1.469 1.469 0 0 1-1.079-.446 1.469 1.469 0 0 1-.445-1.078c0-.422.149-.781.445-1.078a1.469 1.469 0 0 1 1.079-.446c.421 0 .781.149 1.078.446.29.282.452.672.446 1.078.006.406-.155.796-.446 1.078z"/><path fill="#F5A623" d="M16.672 6.367a1.994 1.994 0 0 0-1.462-.607h-6.9c-.57 0-1.058.203-1.463.607A1.995 1.995 0 0 0 6.24 7.83v6.9c0 .57.203 1.058.607 1.463.405.404.893.607 1.463.607h6.9c.57 0 1.058-.203 1.462-.607.405-.405.608-.893.608-1.463v-6.9c0-.57-.203-1.058-.608-1.463zm-5.86 5.991a1.469 1.469 0 0 1-1.079.446 1.469 1.469 0 0 1-1.078-.446 1.469 1.469 0 0 1-.446-1.078c0-.422.15-.781.446-1.078a1.469 1.469 0 0 1 1.078-.446c.422 0 .78.149 1.078.446.291.282.453.672.446 1.078.007.406-.155.796-.446 1.078zm4.053 0a1.468 1.468 0 0 1-1.078.446 1.469 1.469 0 0 1-1.079-.446 1.469 1.469 0 0 1-.445-1.078c0-.422.149-.781.445-1.078a1.469 1.469 0 0 1 1.079-.446c.421 0 .781.149 1.078.446.29.282.452.672.446 1.078.006.406-.155.796-.446 1.078z"/></g></svg>
@@ -0,0 +1,6 @@
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 14 14">
<g fill="none" fill-rule="evenodd">
<path d="M10.101 1.922l3.183 3.473-.206 4.706-3.473 3.183-4.706-.206-3.183-3.473.206-4.706 3.473-3.183z"/>
<path fill="#FFF" stroke="#FFF" d="M3.527 11.132c.416.417.83.833 1.247 1.246.03.03.09.046.137.046 1.424.003 2.847.003 4.272 0a.245.245 0 0 0 .154-.064c1.009-1.004 2.015-2.011 3.02-3.02a.244.244 0 0 0 .067-.154c.004-1.428.003-2.856.002-4.285 0-.039-.01-.09-.034-.116-.418-.424-.839-.845-1.255-1.263l-7.61 7.61m-.577-.572l7.608-7.609c-.408-.408-.821-.824-1.24-1.237a.21.21 0 0 0-.134-.047 937.737 937.737 0 0 0-4.272 0 .241.241 0 0 0-.156.062 1000.334 1000.334 0 0 0-3.03 3.029.211.211 0 0 0-.059.131 1227.38 1227.38 0 0 0 0 4.31.17.17 0 0 0 .04.113c.416.421.835.84 1.243 1.248M13.2 7.053c0 .769-.003 1.536.002 2.304a.536.536 0 0 1-.168.412c-1.091 1.086-2.18 2.175-3.266 3.265a.527.527 0 0 1-.4.168 997.623 997.623 0 0 0-4.644 0 .53.53 0 0 1-.4-.166C3.237 11.942 2.145 10.85 1.05 9.76a.508.508 0 0 1-.16-.389C.892 7.824.892 6.276.889 4.727c0-.162.049-.286.163-.4 1.095-1.09 2.187-2.181 3.276-3.275.11-.11.23-.163.387-.163 1.553.003 3.105.003 4.658 0 .158 0 .278.05.388.161 1.093 1.097 2.188 2.191 3.285 3.285a.498.498 0 0 1 .156.377c-.004.78-.002 1.56-.002 2.341"/>
</g>
</svg>
@@ -93,7 +93,7 @@ class Blocking extends React.Component {
*/
setShow(filterName) {
const updated_categories = JSON.parse(JSON.stringify(this.props.categories)); // deep clone
const updatedAntiTracking = JSON.parse(JSON.stringify(this.props.antiTracking)); // deep clone
const updatedAntiTracking = JSON.parse(JSON.stringify(this.props.unknownCategory)); // deep clone

updated_categories.forEach((category) => {
let count = 0;
@@ -284,7 +284,7 @@ class Blocking extends React.Component {
const {
actions,
categories,
antiTracking,
unknownCategory,
enable_anti_tracking,
expand_all_trackers,
is_expanded,
@@ -329,7 +329,7 @@ class Blocking extends React.Component {
language={language}
smartBlockActive={smartBlockActive}
smartBlock={smartBlock}
antiTracking={antiTracking}
unknownCategory={unknownCategory}
enable_anti_tracking={enable_anti_tracking}
/>
)}
@@ -32,7 +32,7 @@ class Categories extends React.Component {
const {
categories,
expandAll,
antiTracking,
unknownCategory,
enable_anti_tracking,
sitePolicy,
} = this.props;
@@ -47,15 +47,16 @@ class Categories extends React.Component {
name: t('unknown'),
description: t('unknown_description'),
img_name: 'anti_tracking_unknown',
num_total: antiTracking.unknownTrackers.length,
num_blocked: antiTracking.unknownTrackerCount,
num_shown: antiTracking.hide ? 0 : antiTracking.unknownTrackers.length,
trackers: antiTracking.unknownTrackers.map((unknownTracker) => {
num_total: unknownCategory.unknownTrackers.length,
num_blocked: unknownCategory.unknownTrackerCount,
num_shown: unknownCategory.hide ? 0 : unknownCategory.unknownTrackers.length,
trackers: unknownCategory.unknownTrackers.map((unknownTracker) => {
if (unknownTracker.whitelisted) { whitelistedTotal++; }
return {
name: unknownTracker.name,
domains: unknownTracker.domains,
whitelisted: unknownTracker.whitelisted,
type: unknownTracker.type,
siteRestricted: sitePolicy === 1,
blocked: false,
catId: 'anti_tracking_unknown',
@@ -94,13 +95,13 @@ class Categories extends React.Component {
};

const categoryList = categories.map((category, index) => renderCategory(category, index));
const unknownCategory = antiTracking && antiTracking.unknownTrackers.length
const renderUnknownCategory = unknownCategory && unknownCategory.unknownTrackers.length
? renderCategory(null, categoryList.length, true) : null;

return (
<div className="scroll-content">
{categoryList}
{unknownCategory}
{renderUnknownCategory}
</div>
);
}
@@ -200,11 +200,7 @@ class Category extends React.Component {
<div className={`${category.num_shown === 0 ? 'hide' : ''} blocking-category`}>
<div className={`sticky-category${this.state.showTooltip ? ' no-sticky' : ''}${isUnknown ? ' anti-tracking-header' : ''}`}>
{isUnknown && (
<div className="Category__antiTrackingDivider">
<p className="Category__antiTrackingDividerText">
{t('enhanced_anti_tracking')}
</p>
</div>
<div className="Category__antiTrackingDivider" />
)}
<div className="row align-middle">
<div className="columns shrink align-self-top">
@@ -272,20 +268,6 @@ class Category extends React.Component {
</span>
</div>
)}
{isUnknown && (
<div className="Category__antiTrackingButton">
<CliqzFeature
clickButton={clickCliqzFeature}
type="anti_track"
active={enable_anti_tracking}
cliqzInactive={cliqzInactive}
isTiny
isTooltipHeader
isTooltipBody
tooltipPosition="left"
/>
</div>
)}
</div>
</div>
</div>
@@ -345,6 +345,7 @@ class Tracker extends React.Component {
this.handleAntiTrackingWhitelist,
tracker.whitelisted,
tracker.siteRestricted,
tracker.type,
)}
</div>
</div>
@@ -54,7 +54,7 @@ export const renderKnownTrackerButtons = (
);

export const renderUnknownTrackerButtons = (
handleAntiTrackingWhitelist, whitelisted, siteRestricted
handleAntiTrackingWhitelist, whitelisted, siteRestricted, type
) => {
const svgContainerClasses = ClassNames('unknown-svg-container', {
whitelisted: whitelisted && !siteRestricted,
@@ -82,11 +82,20 @@ export const renderUnknownTrackerButtons = (
<g transform="translate(1 1)" fill="none" fillRule="evenodd">
<path className="border" stroke="#00AEF0" d="M-.5-.5h18.3v18.217H-.5z" />
<path className="background" stroke="#FFF" fill="#00AEF0" d="M.5.5h16.3v16.217H.5z" />
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 19.5 19.5">
<g transform="translate(2.5 2.5)">
<path className="shield" fill="none" fillRule="evenodd" stroke="#FFF" strokeWidth="1.4" d="M8.149 1.022a.505.505 0 0 0-.298 0l-6.404 1.7A.574.574 0 0 0 1 3.286c.03 4.56 2.472 8.792 6.672 11.624.09.06.209.089.328.089.12 0 .238-.03.328-.09 4.2-2.83 6.642-7.063 6.672-11.623a.574.574 0 0 0-.447-.566L8.15 1.022z" />
</g>
</svg>
{type === 'antiTracking' ? (
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 19.5 19.5">
<g transform="translate(2.5 2.5)">
<path className="shield" fill="none" fillRule="evenodd" stroke="#FFF" strokeWidth="1.4" d="M8.149 1.022a.505.505 0 0 0-.298 0l-6.404 1.7A.574.574 0 0 0 1 3.286c.03 4.56 2.472 8.792 6.672 11.624.09.06.209.089.328.089.12 0 .238-.03.328-.09 4.2-2.83 6.642-7.063 6.672-11.623a.574.574 0 0 0-.447-.566L8.15 1.022z" />
</g>
</svg>
) : (
<svg xmlns="http://www.w3.org/2000/svg" width="19" height="19" viewBox="0 0 20 20">
<g fill="none" fillRule="evenodd" transform="translate(2 2)">
<path className="shield" d="M10.101 1.922l3.183 3.473-.206 4.706-3.473 3.183-4.706-.206-3.183-3.473.206-4.706 3.473-3.183z" />
<path className="shield" fill="#FFF" stroke="#FFF" d="M3.527 11.132c.416.417.83.833 1.247 1.246.03.03.09.046.137.046 1.424.003 2.847.003 4.272 0a.245.245 0 0 0 .154-.064c1.009-1.004 2.015-2.011 3.02-3.02a.244.244 0 0 0 .067-.154c.004-1.428.003-2.856.002-4.285 0-.039-.01-.09-.034-.116-.418-.424-.839-.845-1.255-1.263l-7.61 7.61m-.577-.572l7.608-7.609c-.408-.408-.821-.824-1.24-1.237a.21.21 0 0 0-.134-.047 937.737 937.737 0 0 0-4.272 0 .241.241 0 0 0-.156.062 1000.334 1000.334 0 0 0-3.03 3.029.211.211 0 0 0-.059.131 1227.38 1227.38 0 0 0 0 4.31.17.17 0 0 0 .04.113c.416.421.835.84 1.243 1.248M13.2 7.053c0 .769-.003 1.536.002 2.304a.536.536 0 0 1-.168.412c-1.091 1.086-2.18 2.175-3.266 3.265a.527.527 0 0 1-.4.168 997.623 997.623 0 0 0-4.644 0 .53.53 0 0 1-.4-.166C3.237 11.942 2.145 10.85 1.05 9.76a.508.508 0 0 1-.16-.389C.892 7.824.892 6.276.889 4.727c0-.162.049-.286.163-.4 1.095-1.09 2.187-2.181 3.276-3.275.11-.11.23-.163.387-.163 1.553.003 3.105.003 4.658 0 .158 0 .278.05.388.161 1.093 1.097 2.188 2.191 3.285 3.285a.498.498 0 0 1 .156.377c-.004.78-.002 1.56-.002 2.341" />
</g>
</svg>
)}
</g>
</svg>
</span>
@@ -41,7 +41,7 @@ const initialState = {
},
site_specific_unblocks: {},
site_specific_blocks: {},
antiTracking: {
unknownCategory: {
totalUnsafeCount: 0, // The amount of data points scrubbed by Anti-Tracking
totalUnknownCount: 0, // The amount of data points scrubbed by Anti-Tracking for Trackers not in the Ghostery DB
trackerCount: 0, // The amount of trackers scrubbed by Anti-Tracking (which are each associated with 1 or more data points)
@@ -99,16 +99,32 @@ export default (state = initialState, action) => {
return Object.assign({}, state, updated);
}
case UPDATE_ANTI_TRACKING_WHITELIST: {
const antiTracking = _updateAntiTrackingWhitelist(state, action);
const antiTracking = _updateCliqzModuleWhitelist(state, action);
return Object.assign({}, state, { antiTracking });
}
case UPDATE_CLIQZ_MODULE_DATA:
case UPDATE_SUMMARY_DATA: {
if (action.data.antiTracking) {
const { hide } = state.antiTracking;
return Object.assign({}, state, {
antiTracking: Object.assign({}, action.data.antiTracking, { hide })
const { antiTracking, adBlock } = action.data;
let adBlockUnknownTrackers = adBlock.unknownTrackers;
antiTracking.unknownTrackers.forEach((tracker) => {
if (tracker.whitelisted) {
adBlockUnknownTrackers = adBlockUnknownTrackers.filter(adBlockTracker => (
adBlockTracker.name !== tracker.name
));
}
});

const unknownCategory = {
totalUnsafeCount: antiTracking.totalUnsafeCount + adBlock.totalUnsafeCount,
totalUnknownCount: antiTracking.totalUnknownCount + adBlock.totalUnknownCount,
trackerCount: antiTracking.trackerCount + adBlock.trackerCount,
unknownTrackerCount: antiTracking.unknownTrackerCount + adBlock.unknownTrackerCount,
unknownTrackers: Array.from(new Set(antiTracking.unknownTrackers.concat(adBlockUnknownTrackers))),
whitelistedUrls: Object.assign({}, antiTracking.whitelistedUrls, adBlock.whitelistedUrls),
hide: state.unknownCategory.hide,
};
return Object.assign({}, state, { unknownCategory });
}
return state;
}
@@ -192,9 +208,9 @@ const _updateTrackerTrustRestrict = (state, action) => {
* @param {Object} action action which provides data
* @return {Object} updated categories and site-specific blocking counters
*/
const _updateAntiTrackingWhitelist = (state, action) => {
const updatedAntiTracking = JSON.parse(JSON.stringify(state.antiTracking));
const { whitelistedUrls } = updatedAntiTracking;
const _updateCliqzModuleWhitelist = (state, action) => {
const updatedUnknownCategory = JSON.parse(JSON.stringify(state.unknownCategory));
const { whitelistedUrls } = updatedUnknownCategory;
const { unknownTracker, pageHost } = action.data;

const addToWhitelist = () => {
@@ -235,13 +251,13 @@ const _updateAntiTrackingWhitelist = (state, action) => {
addToWhitelist();
}

updatedAntiTracking.unknownTrackers.forEach((tracker) => {
updatedUnknownCategory.unknownTrackers.forEach((tracker) => {
if (tracker.name === unknownTracker.name) {
tracker.whitelisted = !tracker.whitelisted;
}
});

sendMessage('setPanelData', { anti_tracking_whitelist: whitelistedUrls });
sendMessage('setPanelData', { cliqz_module_whitelist: whitelistedUrls });

return updatedAntiTracking;
return updatedUnknownCategory;
};
@@ -58,7 +58,7 @@
height: 62px;

&.anti-tracking-header {
height: 80px;
height: 66px;
border-top: 0;
padding-top: 0;
}
@@ -141,27 +141,14 @@
}
}
.Category__antiTrackingDivider {
background-color: #00AEF0;
width: 110%;
height: 18px;
height: 4px;
border-top: 1px solid #00AEF0;
border-bottom: 1px solid #00AEF0;
margin-bottom: 9px;
}
.Category__antiTrackingDividerText {
margin: 0;
padding-top: 2px;
padding-left: 15px;
font-size: 10px;
color: white;
}
.Category__antiTrackingCaret {
position: relative;
bottom: 14px;
left: 8px;
}
.Category__antiTrackingButton {
display: inline-block;
position: relative;
left: 4px;
bottom: 4px
left: -20px;
}
}
@@ -842,13 +842,9 @@ function onMessageHandler(request, sender, callback) {
return false;
}
if (name === 'getCliqzModuleData') { // panel-android only
if (message && message.tabId) {
sendCliqzModuleCounts(message.tabId, callback);
} else {
utils.getActiveTab((tab) => {
sendCliqzModuleCounts(tab.id, callback);
});
}
utils.getActiveTab((tab) => {
sendCliqzModuleCounts(tab.id, tab.pageHost, callback);
});
return true;
}
if (name === 'getTrackerDescription') {
@@ -17,7 +17,7 @@ import conf from './Conf';
import foundBugs from './FoundBugs';
import rewards from './Rewards';
import Policy from './Policy';
import { getCliqzAntiTrackingData, getCliqzAdBlockingCount } from '../utils/cliqzModulesData';
import { getCliqzData } from '../utils/cliqzModulesData';
import { getTab } from '../utils/utils';
import { log } from '../utils/common';
import globals from './Globals';
@@ -131,6 +131,7 @@ class BrowserButton {
*/
_getIconCount(tab) {
const tabId = tab.id;
const tabHostUrl = tab.pageHost;
let trackerCount = '';
let alert = false;

@@ -145,8 +146,8 @@ class BrowserButton {
}

const { appsCount, appsAlertCount } = this._getTrackerCount(tabId);
const adBlockingCount = getCliqzAdBlockingCount(tabId).trackerCount;
const antiTrackingCount = getCliqzAntiTrackingData(tabId).trackerCount;
const adBlockingCount = getCliqzData(tabId, tabHostUrl).trackerCount;
const antiTrackingCount = getCliqzData(tabId, tabHostUrl, true).trackerCount;

alert = (appsAlertCount > 0);
trackerCount = (appsCount + antiTrackingCount + adBlockingCount).toString();
@@ -151,7 +151,7 @@ class ConfData {
_initProperty('site_specific_blocks', {});
_initProperty('site_specific_unblocks', {});
_initProperty('site_whitelist', []);
_initProperty('anti_tracking_whitelist', {});
_initProperty('cliqz_module_whitelist', {});
_initProperty('surrogates', {});
_initProperty('version_history', []);
_initProperty('account', null);
@@ -90,7 +90,7 @@ class Policy {
let isWhitelisted = false;
const processedHostUrl = processUrl(hostUrl).host;
const processedTrackerUrl = processUrl(trackerUrl).host;
const antiTrackingWhitelist = conf.anti_tracking_whitelist;
const antiTrackingWhitelist = conf.cliqz_module_whitelist;

if (antiTrackingWhitelist[processedTrackerUrl]) {
antiTrackingWhitelist[processedTrackerUrl].hosts.some((host) => {
ProTip! Use n and p to navigate between commits in a pull request.