Skip to content

Commit 98e3ee7

Browse files
committed
[core] disable search query delete temporarily and fix chrome.ts
1 parent 26d0d8a commit 98e3ee7

File tree

2 files changed

+66
-55
lines changed

2 files changed

+66
-55
lines changed

src/client/shared/chrome.ts

Lines changed: 63 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,90 +1,101 @@
11
// delete all chrome specific apis, or apis that are not supported by any browser other than chrome
22
// these are not worth emulating and typically cause issues
33

4-
import { isemulatedsw } from "@client/entry";
4+
import { isemulatedsw, iswindow } from "@client/entry";
55
import { ScramjetClient } from "@client/index";
66

77
// type self as any here, most of these are not defined in the types
88
export default function (client: ScramjetClient, self: any) {
9+
const del = (name: string) => {
10+
const split = name.split(".");
11+
const prop = split.pop();
12+
const target = split.reduce((a, b) => a?.[b], self);
13+
if (!target) return;
14+
if (prop && prop in target) {
15+
delete target[prop];
16+
} else {
17+
}
18+
};
19+
920
// obviously
10-
delete self.chrome;
21+
del("chrome");
1122

1223
// ShapeDetector https://developer.chrome.com/docs/capabilities/shape-detection
13-
delete self.BarcodeDetector;
14-
delete self.FaceDetector;
15-
delete self.TextDetector;
24+
del("BarcodeDetector");
25+
del("FaceDetector");
26+
del("TextDetector");
1627

1728
// background synchronization api
18-
if (window) {
19-
delete self.ServiceWorkerRegistration.prototype.sync;
29+
if (iswindow) {
30+
del("ServiceWorkerRegistration.prototype.sync");
2031
}
2132
if (isemulatedsw) {
22-
delete self.SyncManager;
23-
delete self.SyncEvent;
33+
del("SyncManager");
34+
del("SyncEvent");
2435
}
2536

2637
// trustedtypes
27-
delete self.TrustedHTML;
28-
delete self.TrustedScript;
29-
delete self.TrustedScriptURL;
30-
delete self.TrustedTypePolicy;
31-
delete self.TrustedTypePolicyFactory;
38+
del("TrustedHTML");
39+
del("TrustedScript");
40+
del("TrustedScriptURL");
41+
del("TrustedTypePolicy");
42+
del("TrustedTypePolicyFactory");
3243
self.__defineGetter__("trustedTypes", () => undefined);
3344

3445
// whatever this is
35-
delete self.Navigator.prototype.joinAdInterestGroup;
46+
del("Navigator.prototype.joinAdInterestGroup");
3647

37-
if (!window) return;
48+
if (!iswindow) return;
3849
// DOM specific ones below here
3950

40-
delete self.MediaDevices.prototype.setCaptureHandleConfig;
51+
del("MediaDevices.prototype.setCaptureHandleConfig");
4152

4253
// web bluetooth api
43-
delete self.Navigator.prototype.bluetooth;
44-
delete self.Bluetooth;
45-
delete self.BluetoothDevice;
46-
delete self.BluetoothRemoteGATTServer;
47-
delete self.BluetoothRemoteGATTCharacteristic;
48-
delete self.BluetoothRemoteGATTDescriptor;
49-
delete self.BluetoothUUID;
54+
del("Navigator.prototype.bluetooth");
55+
del("Bluetooth");
56+
del("BluetoothDevice");
57+
del("BluetoothRemoteGATTServer");
58+
del("BluetoothRemoteGATTCharacteristic");
59+
del("BluetoothRemoteGATTDescriptor");
60+
del("BluetoothUUID");
5061

5162
// contact picker api
52-
delete self.Navigator.prototype.contacts;
53-
delete self.ContactAddress;
54-
delete self.ContactManager;
63+
del("Navigator.prototype.contacts");
64+
del("ContactAddress");
65+
del("ContactManager");
5566

5667
// Idle Detection API
57-
delete self.IdleDetector;
68+
del("IdleDetector");
5869

5970
// Presentation API
60-
delete self.Navigator.prototype.presentation;
61-
delete self.Presentation;
62-
delete self.PresentationConnection;
63-
delete self.PresentationReceiver;
64-
delete self.PresentationRequest;
65-
delete self.PresentationAvailability;
66-
delete self.PresentationConnectionAvailableEvent;
67-
delete self.PresentationConnectionCloseEvent;
68-
delete self.PresentationConnectionList;
71+
del("Navigator.prototype.presentation");
72+
del("Presentation");
73+
del("PresentationConnection");
74+
del("PresentationReceiver");
75+
del("PresentationRequest");
76+
del("PresentationAvailability");
77+
del("PresentationConnectionAvailableEvent");
78+
del("PresentationConnectionCloseEvent");
79+
del("PresentationConnectionList");
6980

7081
// Window Controls Overlay API
71-
delete self.WindowControlsOverlay;
72-
delete self.WindowControlsOverlayGeometryChangeEvent;
73-
delete self.Navigator.prototype.windowControlsOverlay;
82+
del("WindowControlsOverlay");
83+
del("WindowControlsOverlayGeometryChangeEvent");
84+
del("Navigator.prototype.windowControlsOverlay");
7485

7586
// WebHID API
76-
delete self.Navigator.prototype.hid;
77-
delete self.HID;
78-
delete self.HIDDevice;
79-
delete self.HIDConnectionEvent;
80-
delete self.HIDInputReportEvent;
87+
del("Navigator.prototype.hid");
88+
del("HID");
89+
del("HIDDevice");
90+
del("HIDConnectionEvent");
91+
del("HIDInputReportEvent");
8192

8293
// Navigation API (not chrome only but it's really annoying to implement)
83-
delete self.navigation;
84-
delete self.NavigateEvent;
85-
delete self.NavigationActivation;
86-
delete self.NavigationCurrentEntryChangeEvent;
87-
delete self.NavigationDestination;
88-
delete self.NavigationHistoryEntry;
89-
delete self.NavigationTransition;
94+
del("navigation");
95+
del("NavigateEvent");
96+
del("NavigationActivation");
97+
del("NavigationCurrentEntryChangeEvent");
98+
del("NavigationDestination");
99+
del("NavigationHistoryEntry");
100+
del("NavigationTransition");
90101
}

src/shared/rewriters/url.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ export function rewriteUrl(url: string | URL, meta: URLMeta) {
6262
export function unrewriteUrl(url: string | URL) {
6363
if (url instanceof URL) url = url.toString();
6464
// remove query string
65-
if (url.includes("?")) {
66-
url = url.split("?")[0];
67-
}
65+
// if (url.includes("?")) {
66+
// url = url.split("?")[0];
67+
// }
6868

6969
const prefixed = location.origin + config.prefix;
7070

0 commit comments

Comments
 (0)