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

Never-consent popup clean up #1491

Merged
merged 3 commits into from
Mar 4, 2024
Merged
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
108 changes: 0 additions & 108 deletions extension-manifest-v2/app/autoconsent/index.js

This file was deleted.

13 changes: 0 additions & 13 deletions extension-manifest-v2/app/content-scripts/autoconsent.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,14 @@
*/

import AutoConsent from '@duckduckgo/autoconsent';
import { showIframe } from '@ghostery/ui/iframe';

if (document.contentType === 'text/html') {
const consent = new AutoConsent(msg => chrome.runtime.sendMessage(
{ ...msg, action: 'autoconsent' },
));

let shownIframe = false;
chrome.runtime.onMessage.addListener((msg) => {
if (msg.action === 'autoconsent') {
if (msg.type === 'openIframe') {
if (shownIframe) return false;

showIframe(chrome.runtime.getURL(
`app/templates/autoconsent.html?host=${encodeURIComponent(msg.domain)}`
));
shownIframe = true;

return false;
}

return Promise.resolve(consent.receiveMessageCallback(msg));
}

Expand Down
14 changes: 0 additions & 14 deletions extension-manifest-v2/app/templates/autoconsent.html

This file was deleted.

1 change: 0 additions & 1 deletion extension-manifest-v2/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,6 @@
"web_accessible_resources": [
"app/images/*",
"app/templates/trackers-preview.html",
"app/templates/autoconsent.html",
"app/templates/youtube.html",
"app/templates/renew.html"
]
Expand Down
30 changes: 0 additions & 30 deletions extension-manifest-v2/src/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -567,36 +567,6 @@ function onMessageHandler(request, sender, callback) {
if (origin === 'blocked_redirect') {
return handleBlockedRedirect(name, message, tab_id, callback);
}
if (origin === 'autoconsent') {
if (name === 'enable') {
conf.enable_autoconsent = true;
if (message.url) {
conf.autoconsent_whitelist = (conf.autoconsent_whitelist || []).concat(message.url);
conf.autoconsent_blacklist = conf.autoconsent_blacklist || [];
} else {
conf.autoconsent_whitelist = false;
conf.autoconsent_blacklist = false;
}

account.saveUserSettings().catch(err => log('Background autoconsent', err));

return false;
}
if (name === 'disable') {
if (message.url) {
conf.autoconsent_whitelist = conf.autoconsent_whitelist || [];
conf.autoconsent_blacklist = (conf.autoconsent_blacklist || []).concat(message.url);
} else {
conf.enable_autoconsent = false;
conf.autoconsent_whitelist = [];
conf.autoconsent_blacklist = [];
}

account.saveUserSettings().catch(err => log('Background autoconsent', err));

return false;
}
}

// HANDLE UNIVERSAL EVENTS HERE (NO ORIGIN LISTED ABOVE)
if (name === 'getTabInfo') {
Expand Down
4 changes: 0 additions & 4 deletions extension-manifest-v2/src/classes/Account.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,6 @@ class Account {
});
}

// clean up the autoconsent whitelist/blacklist
delete settings_json.autoconsent_whitelist;
delete settings_json.autoconsent_blacklist;

// @TODO setConfUserSettings settings.settingsJson
this._setConfUserSettings(settings_json);
this._setAccountUserSettings(settings_json);
Expand Down
2 changes: 0 additions & 2 deletions extension-manifest-v2/src/classes/ConfData.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,6 @@ class ConfData {

// Complex props
_initProperty('account', null);
_initProperty('autoconsent_whitelist', []);
_initProperty('autoconsent_blacklist', []);
_initProperty('bugs', {});
_initProperty('click2play', {});
_initProperty('cmp_data', []);
Expand Down
6 changes: 0 additions & 6 deletions extension-manifest-v2/src/classes/PanelData.js
Original file line number Diff line number Diff line change
Expand Up @@ -598,12 +598,6 @@ class PanelData {
tabInfo.setTabInfo(this._activeTab.id, 'needsReload', data.needsReload);
}

if (data.enable_autoconsent === false) {
conf.autoconsent_whitelist = [];
conf.autoconsent_blacklist = [];
syncSetDataChanged = true;
}

if (syncSetDataChanged) {
// TODO: skip it if the user is not logged in (to avoid errors in the debug logs)
account.saveUserSettings().catch((err) => {
Expand Down
35 changes: 3 additions & 32 deletions extension-manifest-v2/src/modules/autoconsent.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ async function getTabDomain(tabId) {
async function initialize(msg, tabId, frameId) {
const {
enable_autoconsent,
autoconsent_whitelist,
autoconsent_blacklist,
site_whitelist,
} = conf;

Expand All @@ -34,13 +32,10 @@ async function initialize(msg, tabId, frameId) {

const domain = await getTabDomain(tabId);

if ((autoconsent_blacklist && autoconsent_blacklist.includes(domain)) || site_whitelist.some(s => s.includes(domain))) {
if (site_whitelist.some(s => s.includes(domain))) {
return;
}

const globallyEnabled = !autoconsent_whitelist;
const optOut = globallyEnabled || autoconsent_whitelist.includes(domain);

chrome.tabs.sendMessage(
tabId,
{
Expand All @@ -49,9 +44,9 @@ async function initialize(msg, tabId, frameId) {
rules,
config: {
enabled: true,
autoAction: optOut ? 'optOut' : '',
autoAction: 'optOut',
disabledCmps: [],
enablePrehide: optOut,
enablePrehide: true,
detectRetries: 20,
},
},
Expand Down Expand Up @@ -88,27 +83,6 @@ async function evalCode(code, id, tabId, frameId) {
);
}

async function openIframe(msg, tabId) {
const { autoconsent_whitelist } = conf;
if (!autoconsent_whitelist) return;

const domain = await getTabDomain(tabId);

if (autoconsent_whitelist.includes(domain)) {
return;
}

chrome.tabs.sendMessage(
tabId,
{
action: 'autoconsent',
type: 'openIframe',
domain,
},
{ frameId: 0 },
);
}

chrome.runtime.onMessage.addListener((msg, sender) => {
if (msg.action !== 'autoconsent') return false;
if (!sender.tab) return false;
Expand All @@ -121,9 +95,6 @@ chrome.runtime.onMessage.addListener((msg, sender) => {
return initialize(msg, tabId, frameId);
case 'eval':
return evalCode(msg.code, msg.id, tabId, frameId);
case 'cmpDetected':
openIframe(msg, tabId);
return false;
default:
return false;
}
Expand Down
2 changes: 0 additions & 2 deletions extension-manifest-v2/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ const PANEL_ANDROID_DIR = path.resolve(__dirname, 'app/panel-android');
const SASS_DIR = path.resolve(__dirname, 'app/scss');
const CONTENT_SCRIPTS_DIR = path.resolve(__dirname, 'app/content-scripts');
const TRACKERS_PREVIEW_DIR = path.resolve(__dirname, 'app/trackers-preview');
const AUTOCONSENT_DIR = path.resolve(__dirname, 'app/autoconsent');
const RENEW_DIR = path.resolve(__dirname, 'app/renew');
const YOUTUBE_DIR = path.resolve(__dirname, 'app/youtube');

Expand Down Expand Up @@ -83,7 +82,6 @@ module.exports = {
shared_comp_react: [`${SHARED_COMP_DIR}/index.js`],
trackers_preview: [`${TRACKERS_PREVIEW_DIR}/index.js`],
trackers_preview_content_script: [`${CONTENT_SCRIPTS_DIR}/trackers-preview.js`],
autoconsent: [`${AUTOCONSENT_DIR}/index.js`],
renew: [`${RENEW_DIR}/index.js`],
youtube: [`${YOUTUBE_DIR}/index.js`],
youtube_content_script: [`${CONTENT_SCRIPTS_DIR}/youtube.js`],
Expand Down
32 changes: 3 additions & 29 deletions extension-manifest-v3/src/background/autoconsent.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,20 @@ import { parse } from 'tldts-experimental';
import { store } from 'hybrids';

import Options from '/store/options.js';
import { sendShowIframeMessage } from '/utils/iframe.js';

async function getTabDomain(tabId) {
return parse((await chrome.tabs.get(tabId)).url).domain;
}

async function initialize(msg, tabId, frameId) {
const { terms, blockAnnoyances, autoconsent, paused } = await store.resolve(
Options,
);
const { terms, blockAnnoyances, paused } = await store.resolve(Options);
const domain = await getTabDomain(tabId);

if (
terms &&
blockAnnoyances &&
!autoconsent.disallowed.includes(domain) &&
(!paused || !paused.some(({ id }) => id === domain))
) {
const optOut = autoconsent.all || autoconsent.allowed.includes(domain);

chrome.tabs.sendMessage(
tabId,
{
Expand All @@ -42,9 +36,9 @@ async function initialize(msg, tabId, frameId) {
rules,
config: {
enabled: true,
autoAction: optOut ? 'optOut' : '',
autoAction: 'optOut',
disabledCmps: [],
enablePrehide: optOut,
enablePrehide: true,
detectRetries: 20,
},
},
Expand Down Expand Up @@ -87,23 +81,6 @@ async function evalCode(code, id, tabId, frameId) {
);
}

async function openIframe(msg, tabId) {
const { autoconsent } = await store.resolve(Options);
if (autoconsent.all) return;

const domain = await getTabDomain(tabId);
if (domain) {
if (autoconsent.allowed.includes(domain)) {
return;
}

sendShowIframeMessage(
tabId,
`pages/autoconsent/index.html?host=${encodeURIComponent(domain)}`,
);
}
}

chrome.runtime.onMessage.addListener((msg, sender) => {
if (msg.action !== 'autoconsent') return;
if (!sender.tab) return;
Expand All @@ -116,9 +93,6 @@ chrome.runtime.onMessage.addListener((msg, sender) => {
return initialize(msg, tabId, frameId);
case 'eval':
return evalCode(msg.code, msg.id, tabId, frameId);
case 'cmpDetected':
openIframe(msg, tabId);
return false;
default:
break;
}
Expand Down
Loading
Loading