cortex_runtime/stealth/
fingerprint.rs1pub const STEALTH_SCRIPT: &str = r#"
5(() => {
6 // Hide webdriver flag
7 Object.defineProperty(navigator, 'webdriver', {
8 get: () => false,
9 configurable: true,
10 });
11
12 // Patch chrome.runtime to look like a real browser
13 if (!window.chrome) {
14 window.chrome = {};
15 }
16 if (!window.chrome.runtime) {
17 window.chrome.runtime = {
18 connect: function() {},
19 sendMessage: function() {},
20 };
21 }
22
23 // Override permissions query to hide "notifications" prompt
24 const originalQuery = window.navigator.permissions.query;
25 window.navigator.permissions.query = (parameters) =>
26 parameters.name === 'notifications'
27 ? Promise.resolve({ state: Notification.permission })
28 : originalQuery(parameters);
29
30 // Patch plugins to appear non-empty
31 Object.defineProperty(navigator, 'plugins', {
32 get: () => [1, 2, 3, 4, 5],
33 configurable: true,
34 });
35
36 // Patch languages
37 Object.defineProperty(navigator, 'languages', {
38 get: () => ['en-US', 'en'],
39 configurable: true,
40 });
41})();
42"#;
43
44pub fn stealth_script() -> &'static str {
46 STEALTH_SCRIPT
47}