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

Support for wtm.page messages #1462

Merged
merged 2 commits into from
Feb 6, 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
2 changes: 1 addition & 1 deletion extension-manifest-v2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"@ghostery/trackers-preview": "^1.0.0",
"@ghostery/ui": "^1.0.0",
"@sentry/browser": "7.1.1",
"@whotracksme/webextension-packages": "^4.0.6",
"@whotracksme/webextension-packages": "^5.0.0",
"classnames": "^2.3.2",
"d3": "^7.8.5",
"foundation-sites": "^6.6.2",
Expand Down
2 changes: 1 addition & 1 deletion extension-manifest-v3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"@ghostery/trackers-preview": "^1.0.0",
"@ghostery/ui": "^1.0.0",
"@github/relative-time-element": "^4.3.0",
"@whotracksme/webextension-packages": "^4.0.6",
"@whotracksme/webextension-packages": "^5.0.0",
"hybrids": "^8.2.5",
"idb": "^7.1.1",
"jwt-decode": "^4.0.0",
Expand Down
20 changes: 6 additions & 14 deletions extension-manifest-v3/src/background/reporting/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ const config = {
COLLECTOR_DIRECT_URL,
COLLECTOR_PROXY_URL,
CONFIG_URL: 'https://api.ghostery.net/api/v1/config',
SAFE_QUORUM_CONFIG_ENDPOINT:
'https://safe-browsing-quorum.privacy.ghostery.net/config',
...platformSpecificSettings(),
},
request: {
Expand All @@ -107,6 +109,7 @@ const communication = new AnonymousCommunication({
const urlReporter = new UrlReporter({
config: config.url,
storage: new Storage('reporting'),
connectDatabase: prefixedIndexedDBKeyValueStore('reporting'),
communication,
});
let requestReporter = null;
Expand Down Expand Up @@ -176,10 +179,6 @@ const setup = asyncSetup([
}),
]);

function delay(timeInMs) {
return new Promise((resolve) => setTimeout(resolve, timeInMs));
}

async function onLocationChange(details) {
try {
setup.pending && (await setup.pending);
Expand Down Expand Up @@ -220,15 +219,7 @@ async function onLocationChange(details) {
}

try {
const jobRegistered = await urlReporter.analyzeUrl(url);
if (jobRegistered) {
// TODO: This part here is not robust:
// we should avoid timers in MV3 or at least assume that we the service
// worker will die (persisting the jobs and shift the scheduling
// responsibility into the reporting module itself could help)
await delay(2000 + 3000 * Math.random());
await urlReporter.processPendingJobs();
}
await urlReporter.analyzeUrl(url);
} catch (e) {
console.warn('Unexpected error in reporting module:', e);
}
Expand All @@ -253,12 +244,13 @@ chrome.runtime.onMessage.addListener((msg, sender) => {
}
});

// for debugging service-workers (TODO: provide a way to control logging)
// for debugging service-workers
globalThis.ghostery = globalThis.ghostery || {};
globalThis.ghostery.WTM = {
communication,
urlReporter,
requestReporter,
config,
webRequestPipeline,
extensionStartedAt: new Date(),
};
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading