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

Selective blocking #1512

Merged
merged 68 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from 67 commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
10d8a9d
Selective blocking in panel UI
smalluban Mar 25, 2024
d5e16f0
Trackers in Settings WIP
smalluban Apr 4, 2024
26d4e37
UI panel updates
smalluban Apr 4, 2024
59d2f0e
Move ui-onboarding-state to v8
smalluban Apr 5, 2024
d88f85e
Minor fixes
smalluban Apr 5, 2024
551db40
Paused state & minor fixes
smalluban Apr 8, 2024
5e2c0d0
Minor fixes
smalluban Apr 9, 2024
f748fe5
Trackers list on settings page
smalluban Apr 9, 2024
4685920
Merge remote-tracking branch 'origin/main' into mv3-feat-selective-bl…
smalluban Apr 10, 2024
7fad47b
Update trackers list
smalluban Apr 10, 2024
3bb6f75
Fix fonts in Firefox
smalluban Apr 10, 2024
121e029
Fix panel action styling
smalluban Apr 10, 2024
ec4c2a7
Minor fixes
smalluban Apr 10, 2024
c1c2bf1
Clear all from category
smalluban Apr 11, 2024
4c80437
Minor fixes
smalluban Apr 11, 2024
a4bb677
Selective blocking: offscreen DNR converter (#1529)
chrmod Apr 11, 2024
b5aa6d4
Merge remote-tracking branch 'origin/main' into mv3-feat-selective-bl…
smalluban Apr 12, 2024
10daeb1
Build: fix for missing optional_permissions
chrmod Apr 12, 2024
4b6521c
Merge branch 'main' into mv3-feat-selective-blocking
chrmod Apr 12, 2024
34b69b2
Merge branch 'main' into mv3-feat-selective-blocking
chrmod Apr 15, 2024
1714f3d
Update hybrids
smalluban Apr 16, 2024
eb78045
Adblocker: integrate fixes ruleset and engines
chrmod Apr 15, 2024
1388d19
Trackerdb integration
chrmod Apr 15, 2024
5abac06
Merge branch 'main' into mv3-feat-selective-blocking
smalluban Apr 17, 2024
9bb6a41
Update hybrids
smalluban Apr 17, 2024
40e7d94
SImplify download scripts
smalluban Apr 17, 2024
377f77d
Fix panel navigation
smalluban Apr 17, 2024
212b937
Selective blocking for Firefox (#1541)
chrmod Apr 17, 2024
5770917
Bug fixes for Firefox selective blocking
chrmod Apr 17, 2024
28cd42d
Tracker Details Layout
smalluban Apr 17, 2024
853fb2a
Minor fixes
smalluban Apr 18, 2024
fc9775d
Fix back url
smalluban Apr 18, 2024
ef8678c
Update metadata creation for unidentified trackers (#1546)
smalluban Apr 18, 2024
ce59111
Show unidentified tracks on panel list
smalluban Apr 18, 2024
bb0e71b
Show settings icon for trackers other than unidentified
smalluban Apr 18, 2024
83f3e90
DNR rules for selective blocking
chrmod Apr 17, 2024
23fe697
Fix linter error
chrmod Apr 18, 2024
3618997
Merge branch 'main' into mv3-feat-selective-blocking
chrmod Apr 18, 2024
d1d7336
Merge branch 'main' into mv3-feat-selective-blocking
smalluban Apr 18, 2024
fb036a1
Merge remote-tracking branch 'origin/mv3-feat-selective-blocking' int…
smalluban Apr 18, 2024
acf00af
Bring back my account to navigation
smalluban Apr 18, 2024
7126c84
Minor fixes
smalluban Apr 18, 2024
27ac461
Fixes
chrmod Apr 18, 2024
d124235
Minor fixes
smalluban Apr 19, 2024
183adbf
MV2: Trust logic (#1547)
chrmod Apr 19, 2024
f89c375
Updates to Tracker Details page
smalluban Apr 19, 2024
8d915cf
Panel UI fixes
smalluban Apr 19, 2024
6305c96
Fix isTrusted trackerDB helper function (#1549)
smalluban Apr 22, 2024
b7345e4
Minor fixes
smalluban Apr 22, 2024
a605dfb
Leftover import
smalluban Apr 22, 2024
7a17db4
Bring back await for trackerDB
smalluban Apr 22, 2024
2b1b878
Merge remote-tracking branch 'origin/main' into mv3-feat-selective-bl…
smalluban Apr 22, 2024
9ab1f75
MV3: Trust logic (#1551)
chrmod Apr 22, 2024
8655285
DNR fixes
chrmod Apr 22, 2024
dd420af
Tracker Details updates
smalluban Apr 22, 2024
5c2e4ab
Tab detection fix
chrmod Apr 23, 2024
5b4a259
Merge branch 'main' into mv3-feat-selective-blocking
chrmod Apr 23, 2024
ae48bdd
npm dedup
chrmod Apr 23, 2024
b0116ee
Minor fixes
smalluban Apr 23, 2024
210ae12
Simplify TrackerException fields
smalluban Apr 25, 2024
e14ce8f
Minor fixes
smalluban Apr 25, 2024
e6450d6
Minor fixes
smalluban Apr 25, 2024
4d098ce
Remove migrating specific trackers settings
smalluban Apr 26, 2024
726c768
Fix tooltip hiding to fast
smalluban Apr 26, 2024
f6884fb
Update translations
smalluban Apr 26, 2024
0e0f753
Simplify DNR converter (#1555)
smalluban Apr 29, 2024
bf10d74
Merge branch 'main' into mv3-feat-selective-blocking
chrmod Apr 29, 2024
6d3a812
Cleaner tests
chrmod Apr 29, 2024
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
3 changes: 2 additions & 1 deletion extension-manifest-v2/app/panel-android/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@

import React from 'react';
import ReactDOM from 'react-dom';
import '@ghostery/ui/pages';

import PanelAndroid from './components/PanelAndroid';
import '../panel/elements/onboarding-state';

import '../scss/panel_android.scss';

ReactDOM.render(
Expand Down
2 changes: 1 addition & 1 deletion extension-manifest-v2/app/panel/components/Summary.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
import React from 'react';
import { ReactSVG } from 'react-svg';
import ClassNames from 'classnames';
import '@ghostery/ui/pages';

import '../elements/onboarding-state';
import Tooltip from '../../shared-components/Tooltip';
import DynamicUIPortContext from '../contexts/DynamicUIPortContext';
import { sendMessage } from '../utils/msg';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0
*/

import { html } from 'hybrids';
import { define, html } from 'hybrids';

export default {
disabled: false,
href: '',
render: ({ disabled, href }) => html`
export default define({
tag: 'ui-onboarding-state',
disabled: false,
href: '',
render: ({ disabled, href }) => html`
<template
layout="column content:center relative"
layout[disabled]="height::120px"
Expand All @@ -25,22 +26,21 @@ export default {
id="disabled"
layout="column center gap:2 margin absolute inset layer:1"
>
<ui-text type="label-m" color="error-500" layout="block:center">
<span layout="block:center">
<ui-icon name="warning" layout="block inline"></ui-icon><br />
Additional Permissions Required
</ui-text>
<ui-text class="button" type="label-m" color="white">
</span>
<span class="button">
Enable Ghostery
</ui-text>
</span>
<a layout="absolute inset layer:3" href="${href}" target="_blank"></a>
</section>
`}
<div id="content"><slot></slot></div>
</template>
`.css`

:host([disabled]) {
border: 1px dashed var(--ui-color-error-500);
border: 1px dashed #ff4500;
border-radius: 4px;
}

Expand All @@ -57,7 +57,13 @@ export default {
background: rgba(255, 243, 238, 0.8);
}

ui-text.button {
span {
font: 500 14px / 18px Roboto, sans-serif;
color: #ff4500;
}

span.button {
color: white;
background: #00AEF0;
border-radius: 2px;
padding: 8px 12px;
Expand All @@ -67,4 +73,4 @@ export default {
z-index: 0;
}
`,
};
});
3 changes: 0 additions & 3 deletions extension-manifest-v2/app/scss/panel.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@
// Import shared helpers
@import 'shared_helper_classes';

// ghostery-ui
// @import "@ghostery/ui/src/styles/pages.css";

html body {
margin: 0px;
font-size: 75%;
Expand Down
2 changes: 1 addition & 1 deletion extension-manifest-v2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"foundation-sites": "^6.6.2",
"ghostery-common": "^1.3.12",
"history": "^4.10.1",
"hybrids": "^8.2.14",
"hybrids": "^8.2.22",
"linkedom": "^0.16.11",
"moment": "^2.29.1",
"prop-types": "^15.6.2",
Expand Down
10 changes: 5 additions & 5 deletions extension-manifest-v3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@
"scripts": {
"download-engines": "node scripts/download-engines/index.js",
"download-whotracksme-bloomfilter": "node scripts/download-whotracksme-bloomfilter.js",
"download": "npm run download-engines && npm run download-whotracksme-bloomfilter",
"download.staging": "npm run download-engines -- --staging && npm run download-whotracksme-bloomfilter",
"build": "node scripts/build.js",
"start": "npm run build -- --watch",
"licenses": "license-report --config=../.license-report-config.json > dist/licenses.html",
"lint": "eslint src/",
"test": "npm run lint",
"test": "node --test && npm run lint",
"locales.ui": "hybrids extract -c --format=chrome.i18n ../node_modules/@ghostery/ui ./src/_locales/en/messages.json",
"locales.src": "hybrids extract -c --format=chrome.i18n ./src ./src/_locales/en/messages.json",
"locales": "npm run locales.ui && npm run locales.src",
Expand All @@ -28,8 +26,10 @@
"license": "MPL-2.0",
"devDependencies": {
"shelljs": "^0.8.5",
"sinon-chrome": "^3.0.1",
"vite": "^4.5.2",
"web-ext": "^7.11.0"
"web-ext": "^7.11.0",
"webextension-polyfill": "^0.11.0"
},
"dependencies": {
"@cliqz/adblocker": "^1.27.1",
Expand All @@ -40,7 +40,7 @@
"@ghostery/ui": "^1.0.0",
"@github/relative-time-element": "^4.3.0",
"@whotracksme/webextension-packages": "^5.0.11",
"hybrids": "^8.2.14",
"hybrids": "^8.2.22",
"idb": "^7.1.1",
"jwt-decode": "^4.0.0",
"tldts-experimental": "^6.0.19"
Expand Down
32 changes: 26 additions & 6 deletions extension-manifest-v3/scripts/build.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { resolve, dirname } from 'path';
import { readFileSync, writeFileSync } from 'fs';
import { resolve, dirname, join } from 'path';
import { readFileSync, writeFileSync, readdirSync } from 'fs';
import { exec, execSync } from 'child_process';
import { build } from 'vite';
import shelljs from 'shelljs';
Expand Down Expand Up @@ -67,14 +67,16 @@ if (argv.target === 'safari') {
options.assets.push('background/safari');
}

// Download adblocker engines
if (argv.staging) {
execSync('npm run download.staging', { stdio: 'inherit' });

execSync('npm run download-engines -- --staging', { stdio: 'inherit' });
manifest.debug = true;
} else {
execSync('npm run download', { stdio: 'inherit' });
execSync('npm run download-engines', { stdio: 'inherit' });
}

execSync('npm run download-whotracksme-bloomfilter', { stdio: 'inherit' });

const config = {
logLevel: argv.silent ? 'silent' : undefined,
configFile: false,
Expand Down Expand Up @@ -114,7 +116,7 @@ options.assets.forEach((path) => {
// copy adblocker engines
shelljs.mkdir('-p', resolve(options.outDir, 'rule_resources'));

const engines = ['ads', 'tracking', 'annoyances'];
const engines = ['ads', 'tracking', 'annoyances', 'fixes'];
const engineType = argv.target === 'firefox' ? '' : '-cosmetics';

engines.forEach((engine) => {
Expand Down Expand Up @@ -173,6 +175,10 @@ execSync('npm run licenses', { stdio: 'inherit' });
// set manifest version from package.json
manifest.version = pkg.version;

if (manifest.permissions.includes('declarativeNetRequest') && argv.watch) {
manifest.permissions.push('declarativeNetRequestFeedback');
}

writeFileSync(
resolve(options.outDir, 'manifest.json'),
JSON.stringify(manifest, null, 2),
Expand All @@ -191,6 +197,20 @@ if (manifest.browser_action?.default_popup) {
source.push(manifest.browser_action.default_popup);
}

// offscreen documents
if (
manifest.permissions.includes('offscreen') ||
manifest.optional_permissions?.includes('offscreen')
) {
readdirSync(join(options.srcDir, 'pages', 'offscreen'), {
withFileTypes: true,
})
.filter((dirent) => dirent.isDirectory() && !dirent.name.startsWith('.'))
.forEach((dirent) =>
source.push(join('pages', 'offscreen', dirent.name, 'index.html')),
);
}

// options page
if (manifest.options_ui?.page) {
source.push(manifest.options_ui?.page);
Expand Down
58 changes: 10 additions & 48 deletions extension-manifest-v3/scripts/download-engines/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ const ENGINES = {
'dnr-cosmetics-ads': 'ads-cosmetics',
'dnr-cosmetics-tracking': 'tracking-cosmetics',
'dnr-cosmetics-annoyances': 'annoyances-cosmetics',
'dnr-fixes': 'fixes',
'dnr-cosmetics-fixes': 'fixes-cosmetics',
'trackerdbMv3': 'trackerdb',
};

Expand Down Expand Up @@ -86,17 +88,14 @@ for (const [name, target] of Object.entries(ENGINES)) {
writeFileSync(outputPath, new Uint8Array(rules));
}

const DNR = staging
? {
'dnr-ads': 'ads',
'dnr-tracking': 'tracking',
'dnr-annoyances': 'annoyances',
}
: {
'dnr-ads-2': 'ads',
'dnr-tracking-2': 'tracking',
'dnr-annoyances-2': 'annoyances',
};
const DNR = {
'dnr-ads': 'ads',
'dnr-tracking': 'tracking',
'dnr-annoyances': 'annoyances',
'dnr-fixes': 'fixes',
'dnr-ios': 'safari',
'dnr-trackerdb': 'trackerdb',
};

for (const [name, target] of Object.entries(DNR)) {
console.log(`Downloading "${name}"...`);
Expand All @@ -119,7 +118,6 @@ for (const [name, target] of Object.entries(DNR)) {
const outputPath = `${TARGET_PATH}/dnr-${target}.json`;

if (
staging &&
existsSync(outputPath) &&
checksum(readFileSync(outputPath)) === list.dnr.checksum
) {
Expand All @@ -140,39 +138,3 @@ for (const [name, target] of Object.entries(DNR)) {
writeFileSync(outputPath, dnr);
}
}

/* DNR for Safari */

console.log(`Downloading "dnr-ios"...`);
const outputPath = `${TARGET_PATH}/dnr-safari.json`;

const list = await fetch(
`https://staging-cdn.ghostery.com/adblocker/configs/dnr-ios/allowed-lists.json`,
).then((res) => {
if (!res.ok) {
throw new Error(
`Failed to download allowed list for dnr-ios": ${res.status}: ${res.statusText}`,
);
}

return res.json();
});

if (
!existsSync(outputPath) ||
checksum(readFileSync(outputPath)) !== list.dnr.checksum
) {
const dnr = await fetch(list.dnr.url || list.dnr.network).then((res) => {
if (!res.ok) {
throw new Error(
`Failed to fetch DNR rules for "${name}": ${res.status}: ${res.statusText}`,
);
}

return res.text();
});

writeFileSync(outputPath, dnr);
} else {
console.log('Checksum match - skipping download');
}
Loading
Loading