@whotracksme/reporting 7.6.0 β†’ 7.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,27 @@
1
+ # v7.7.1 (Mon Sep 15 2025)
2
+
3
+ #### πŸ› Bug Fix
4
+
5
+ - Fix: offscreen window size attributes [#167](https://github.com/whotracksme/webextension-packages/pull/167) ([@chrmod](https://github.com/chrmod))
6
+
7
+ #### Authors: 1
8
+
9
+ - Krzysztof Modras ([@chrmod](https://github.com/chrmod))
10
+
11
+ ---
12
+
13
+ # v7.7.0 (Tue Aug 26 2025)
14
+
15
+ #### πŸš€ Enhancement
16
+
17
+ - "alive" signal: distinguish Brave from Chrome [#165](https://github.com/whotracksme/webextension-packages/pull/165) ([@philipp-classen](https://github.com/philipp-classen))
18
+
19
+ #### Authors: 1
20
+
21
+ - Philipp Claßen ([@philipp-classen](https://github.com/philipp-classen))
22
+
23
+ ---
24
+
1
25
  # v7.6.0 (Tue Aug 26 2025)
2
26
 
3
27
  #### πŸš€ Enhancement
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whotracksme/reporting",
3
- "version": "7.6.0",
3
+ "version": "7.7.1",
4
4
  "type": "module",
5
5
  "description": "",
6
6
  "scripts": {
@@ -29,6 +29,7 @@ module.exports = [
29
29
  copy({
30
30
  targets: [
31
31
  { src: 'src/offscreen/doublefetch/index.html', dest: 'example/offscreen/doublefetch/' },
32
+ { src: 'src/offscreen/doublefetch/offscreen-fix.js', dest: 'example/offscreen/doublefetch/' },
32
33
  ]
33
34
  })
34
35
  ]
@@ -10,7 +10,7 @@
10
10
  */
11
11
 
12
12
  import logger from './logger';
13
- import { requireParam, requireString } from './utils';
13
+ import { requireParam, requireString, lazyInitAsync } from './utils';
14
14
  import Bowser from 'bowser';
15
15
 
16
16
  /**
@@ -30,16 +30,14 @@ export default class AliveMessageGenerator {
30
30
  this.storage = requireParam(storage);
31
31
  this.storageKey = requireString(storageKey);
32
32
  this.navigatorApi = navigatorApi || globalThis.navigator;
33
- }
34
-
35
- get staticConfig() {
36
- this._staticConfig ||= this._generateBaseConfig();
37
- return this._staticConfig;
33
+ this.staticConfigProvider = lazyInitAsync(
34
+ this._generateBaseConfig.bind(this),
35
+ );
38
36
  }
39
37
 
40
38
  async generateMessage(ctry, hour) {
41
39
  const config = {
42
- ...this.staticConfig,
40
+ ...(await this.staticConfigProvider()),
43
41
  ctry,
44
42
  };
45
43
 
@@ -74,12 +72,19 @@ export default class AliveMessageGenerator {
74
72
  };
75
73
  }
76
74
 
77
- _generateBaseConfig() {
75
+ async _generateBaseConfig() {
78
76
  let browser, version, os, platform, engine;
79
77
  const { language, userAgent } = this.navigatorApi;
80
78
  if (userAgent) {
81
79
  const browserInfo = Bowser.parse(userAgent);
82
80
  browser = browserInfo.browser?.name;
81
+ if (browser === 'Chrome' && (await this._looksLikeBrave())) {
82
+ logger.debug(
83
+ 'Chrome user agent detected, but the API says it is Brave',
84
+ );
85
+ browser = 'Chrome (Brave)';
86
+ }
87
+
83
88
  os = browserInfo.os?.name;
84
89
  platform = browserInfo.platform?.type;
85
90
  engine = browserInfo.engine?.name;
@@ -143,4 +148,14 @@ export default class AliveMessageGenerator {
143
148
  _deterministicStringify(obj) {
144
149
  return JSON.stringify(Object.fromEntries(Object.entries(obj).sort()));
145
150
  }
151
+
152
+ async _looksLikeBrave() {
153
+ try {
154
+ return !!(
155
+ this.navigatorApi.brave && (await this.navigatorApi.brave.isBrave())
156
+ );
157
+ } catch (e) {
158
+ return false;
159
+ }
160
+ }
146
161
  }
@@ -309,8 +309,8 @@ async function tryCloseOffscreenDocument() {
309
309
  }
310
310
  }
311
311
  }
312
-
313
- const OFFSCREEN_DOCUMENT_PATH = 'offscreen/doublefetch/index.html';
312
+ const OFFSCREEN_DOCUMENT_PREFIX = 'offscreen/doublefetch';
313
+ const OFFSCREEN_DOCUMENT_PATH = `${OFFSCREEN_DOCUMENT_PREFIX}/index.html`;
314
314
 
315
315
  async function withOffscreenDocumentReady(url, headers, asyncCallback) {
316
316
  const cleanups = [];
@@ -335,6 +335,29 @@ async function withOffscreenDocumentReady(url, headers, asyncCallback) {
335
335
  const undoDNRChange = await addDNRSessionRule(rule);
336
336
  cleanups.push(undoDNRChange);
337
337
 
338
+ await chrome.scripting.registerContentScripts([
339
+ {
340
+ id: 'offscreen-fix',
341
+ matches: [`https://*.${domain}/*`, `https://${domain}/*`],
342
+ js: [`${OFFSCREEN_DOCUMENT_PREFIX}/offscreen-fix.js`],
343
+ runAt: 'document_start',
344
+ allFrames: true,
345
+ world: 'MAIN',
346
+ },
347
+ ]);
348
+ cleanups.push(() => {
349
+ chrome.scripting
350
+ .unregisterContentScripts({
351
+ ids: ['offscreen-fix'],
352
+ })
353
+ .catch((e) => {
354
+ logger.error(
355
+ 'cleanup failed: unable to remove offscreen content script:',
356
+ e,
357
+ );
358
+ });
359
+ });
360
+
338
361
  const undoHeaderOverride = await headerOverride({
339
362
  headers,
340
363
  url,
@@ -0,0 +1,13 @@
1
+ if (window.outerWidth === 0) {
2
+ Object.defineProperty(window, 'outerWidth', {
3
+ get: () => 1920,
4
+ configurable: true,
5
+ });
6
+ }
7
+
8
+ if (window.outerHeight === 0) {
9
+ Object.defineProperty(window, 'outerHeight', {
10
+ get: () => 1080,
11
+ configurable: true,
12
+ });
13
+ }
@@ -162,6 +162,30 @@ describe('#AliveMessageGenerator', function () {
162
162
  t: '2024010203',
163
163
  });
164
164
  });
165
+
166
+ it('should detect Brave', async function () {
167
+ // Brave uses the Chrome user agent, but extended the navigator API to detect it
168
+ navigatorApi.userAgent =
169
+ 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36';
170
+ navigatorApi.language = 'de-DE';
171
+ navigatorApi.brave = {
172
+ async isBrave() {
173
+ return true;
174
+ },
175
+ };
176
+
177
+ const message = await uut.generateMessage('de', '2025082113');
178
+ expect(message).to.eql({
179
+ browser: 'Chrome (Brave)',
180
+ version: '139', // Chrome major version (though taken from Brave 1.81.136)
181
+ os: 'Linux',
182
+ platform: 'desktop',
183
+ engine: 'Blink',
184
+ language: 'de-DE', // from window.navigator
185
+ ctry: 'de',
186
+ t: '2025082113',
187
+ });
188
+ });
165
189
  });
166
190
 
167
191
  describe('if quorum is not reached', function () {