Skip to content

Commit 4f57c25

Browse files
authored
Merge pull request #38 from reclaimprotocol/fix/stealth-injection-race
fix: run stealth injected.js as document_start main-world content script
2 parents e187dee + bf0f54d commit 4f57c25

2 files changed

Lines changed: 21 additions & 13 deletions

File tree

images/minimal-vnc-desktop/extensions/proxy/content.js

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,24 @@
44
(function() {
55
'use strict';
66

7-
// Hide the mouse cursor everywhere. This is a touch/kiosk stream: the pointer
8-
// is a server-side software cursor baked into the VNC framebuffer, and
9-
// unclutter only hides it while idle — it reappears over native popups
10-
// (<select>, date pickers). Setting cursor:none on page content makes
11-
// Chromium report a blank cursor to X, so nothing is drawn. Re-applies on
12-
// every navigation because the content script runs per document.
7+
// A global cursor rule, injected at document_start on every document:
8+
//
9+
// 1. cursor:none — this is a touch/kiosk stream; the pointer is a server-side
10+
// software cursor baked into the VNC framebuffer, and unclutter only hides
11+
// it while idle (it reappears over native <select>/date pickers). cursor:none
12+
// on page content makes Chromium report a blank cursor to X, so none is drawn.
13+
//
14+
//
15+
// Re-applies on every navigation because the content script runs per document.
1316
try {
1417
const cs = document.createElement('style');
1518
cs.textContent = '*,*::before,*::after{cursor:none!important}';
1619
(document.head || document.documentElement).appendChild(cs);
1720
} catch (_) {}
1821

19-
// Inject the page-level script
20-
const script = document.createElement('script');
21-
script.src = chrome.runtime.getURL('injected.js');
22-
script.onload = function() {
23-
this.remove();
24-
};
25-
(document.head || document.documentElement).appendChild(script);
22+
// injected.js runs as a MAIN-world content script (see manifest) so its
23+
// stealth patches install synchronously at document_start, before any page
24+
// script.
2625

2726
// ---- JS dialog bridge (isolated world half) -------------------------------
2827
// injected.js overrides alert/confirm/prompt in the PAGE world so Chromium never

images/minimal-vnc-desktop/extensions/proxy/manifest.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@
1414
"service_worker": "background.js"
1515
},
1616
"content_scripts": [
17+
{
18+
"matches": ["<all_urls>"],
19+
"js": ["injected.js"],
20+
"run_at": "document_start",
21+
"world": "MAIN",
22+
"all_frames": true,
23+
"match_about_blank": true,
24+
"match_origin_as_fallback": true
25+
},
1726
{
1827
"matches": ["<all_urls>"],
1928
"js": ["content.js"],

0 commit comments

Comments
 (0)