asdf98 commited on
Commit
e1ef242
·
verified ·
1 Parent(s): c4b3d73

fix: rename blocked-domain init global to LumaRef

Browse files
Files changed (1) hide show
  1. src-tauri/src/adblock/scripts.rs +71 -71
src-tauri/src/adblock/scripts.rs CHANGED
@@ -1,71 +1,71 @@
1
- /// Builds the complete initialization script injected into every child webview
2
- /// before any page JavaScript runs.
3
- pub fn build_init_script(blocked_domains_json: &str) -> String {
4
- let adblock_layer1 = include_str!("../../resources/scripts/adblock_layer1.js");
5
- let cookie_consent = include_str!("../../resources/scripts/cookie_consent.js");
6
- let webrtc_protect = include_str!("../../resources/scripts/webrtc_protect.js");
7
- let canvas_noise = include_str!("../../resources/scripts/canvas_noise.js");
8
- let hover_overlay = hover_overlay_script();
9
- let vault_detector = vault_detector_script();
10
- let autofill_suppress = autofill_suppress_script();
11
- let video_ad_scriptlets = include_str!("../../resources/scripts/video_ad_scriptlets.js");
12
-
13
- format!(
14
- r#"(function() {{
15
- 'use strict';
16
- window.__MUSE_BLOCKED_DOMAINS__ = {blocked_domains_json};
17
- document.addEventListener('contextmenu', function(e) {{
18
- e.preventDefault();
19
- try {{
20
- const target = e.target;
21
- const info = {{
22
- x: e.screenX, y: e.screenY, clientX: e.clientX, clientY: e.clientY,
23
- tagName: target.tagName, src: target.src || null,
24
- href: target.closest('a') ? target.closest('a').href : null,
25
- text: window.getSelection().toString().slice(0, 200) || null,
26
- pageUrl: location.href,
27
- }};
28
- window.__TAURI_INTERNALS__.invoke('browser_context_menu', info).catch(function() {{}});
29
- }} catch(ex) {{}}
30
- }}, true);
31
- }})();
32
- {video_ad_scriptlets}
33
- {adblock_layer1}
34
- {cookie_consent}
35
- {webrtc_protect}
36
- {canvas_noise}
37
- {autofill_suppress}
38
- {hover_overlay}
39
- {vault_detector}"#
40
- )
41
- }
42
-
43
- /// Image hover overlay script.
44
- pub fn hover_overlay_script() -> &'static str {
45
- include_str!("../../resources/scripts/hover_overlay.js")
46
- }
47
-
48
- /// Password vault form detection + autofill script.
49
- pub fn vault_detector_script() -> &'static str {
50
- include_str!("../../resources/scripts/vault_detector.js")
51
- }
52
-
53
- /// Suppress native browser autofill so Muse vault is the only credential source.
54
- pub fn autofill_suppress_script() -> &'static str {
55
- include_str!("../../resources/scripts/autofill_suppress.js")
56
- }
57
-
58
- /// Known ad/tracker domains for fast JS-side lookup
59
- pub fn blocked_domains_json() -> String {
60
- let domains: &[&str] = &[
61
- "googlesyndication.com", "doubleclick.net", "google-analytics.com",
62
- "googletagmanager.com", "facebook.net", "connect.facebook.net",
63
- "amazon-adsystem.com", "criteo.com", "outbrain.com", "taboola.com",
64
- "scorecardresearch.com", "quantserve.com", "adnxs.com", "rubiconproject.com",
65
- "pubmatic.com", "openx.net", "moatads.com", "hotjar.com", "mixpanel.com",
66
- "segment.io", "segment.com", "amplitude.com", "fullstory.com",
67
- "onetrust.com", "cookielaw.org", "trustarc.com", "consensu.org",
68
- "2mdn.net", "adsymptotic.com", "advertising.com", "bluekai.com",
69
- ];
70
- serde_json::to_string(domains).unwrap_or_else(|_| "[]".to_string())
71
- }
 
1
+ /// Builds the complete initialization script injected into every child webview
2
+ /// before any page JavaScript runs.
3
+ pub fn build_init_script(blocked_domains_json: &str) -> String {
4
+ let adblock_layer1 = include_str!("../../resources/scripts/adblock_layer1.js");
5
+ let cookie_consent = include_str!("../../resources/scripts/cookie_consent.js");
6
+ let webrtc_protect = include_str!("../../resources/scripts/webrtc_protect.js");
7
+ let canvas_noise = include_str!("../../resources/scripts/canvas_noise.js");
8
+ let hover_overlay = hover_overlay_script();
9
+ let vault_detector = vault_detector_script();
10
+ let autofill_suppress = autofill_suppress_script();
11
+ let video_ad_scriptlets = include_str!("../../resources/scripts/video_ad_scriptlets.js");
12
+
13
+ format!(
14
+ r#"(function() {{
15
+ 'use strict';
16
+ window.__LUMAREF_BLOCKED_DOMAINS__ = {blocked_domains_json};
17
+ document.addEventListener('contextmenu', function(e) {{
18
+ e.preventDefault();
19
+ try {{
20
+ const target = e.target;
21
+ const info = {{
22
+ x: e.screenX, y: e.screenY, clientX: e.clientX, clientY: e.clientY,
23
+ tagName: target.tagName, src: target.src || null,
24
+ href: target.closest('a') ? target.closest('a').href : null,
25
+ text: window.getSelection().toString().slice(0, 200) || null,
26
+ pageUrl: location.href,
27
+ }};
28
+ window.__TAURI_INTERNALS__.invoke('browser_context_menu', info).catch(function() {{}});
29
+ }} catch(ex) {{}}
30
+ }}, true);
31
+ }})();
32
+ {video_ad_scriptlets}
33
+ {adblock_layer1}
34
+ {cookie_consent}
35
+ {webrtc_protect}
36
+ {canvas_noise}
37
+ {autofill_suppress}
38
+ {hover_overlay}
39
+ {vault_detector}"#
40
+ )
41
+ }
42
+
43
+ /// Image hover overlay script.
44
+ pub fn hover_overlay_script() -> &'static str {
45
+ include_str!("../../resources/scripts/hover_overlay.js")
46
+ }
47
+
48
+ /// Password vault form detection + autofill script.
49
+ pub fn vault_detector_script() -> &'static str {
50
+ include_str!("../../resources/scripts/vault_detector.js")
51
+ }
52
+
53
+ /// Suppress native browser autofill so the LumaRef vault is the only credential source.
54
+ pub fn autofill_suppress_script() -> &'static str {
55
+ include_str!("../../resources/scripts/autofill_suppress.js")
56
+ }
57
+
58
+ /// Known ad/tracker domains for fast JS-side lookup
59
+ pub fn blocked_domains_json() -> String {
60
+ let domains: &[&str] = &[
61
+ "googlesyndication.com", "doubleclick.net", "google-analytics.com",
62
+ "googletagmanager.com", "facebook.net", "connect.facebook.net",
63
+ "amazon-adsystem.com", "criteo.com", "outbrain.com", "taboola.com",
64
+ "scorecardresearch.com", "quantserve.com", "adnxs.com", "rubiconproject.com",
65
+ "pubmatic.com", "openx.net", "moatads.com", "hotjar.com", "mixpanel.com",
66
+ "segment.io", "segment.com", "amplitude.com", "fullstory.com",
67
+ "onetrust.com", "cookielaw.org", "trustarc.com", "consensu.org",
68
+ "2mdn.net", "adsymptotic.com", "advertising.com", "bluekai.com",
69
+ ];
70
+ serde_json::to_string(domains).unwrap_or_else(|_| "[]".to_string())
71
+ }