|
| 1 | +// delete all chrome specific apis, or apis that are not supported by any browser other than chrome |
| 2 | +// these are not worth emulating and typically cause issues |
| 3 | + |
| 4 | +import { isemulatedsw } from "@client/entry"; |
| 5 | +import { ScramjetClient } from "@client/index"; |
| 6 | + |
| 7 | +// type self as any here, most of these are not defined in the types |
| 8 | +export default function (client: ScramjetClient, self: any) { |
| 9 | + // obviously |
| 10 | + delete self.chrome; |
| 11 | + |
| 12 | + // ShapeDetector https://developer.chrome.com/docs/capabilities/shape-detection |
| 13 | + delete self.BarcodeDetector; |
| 14 | + delete self.FaceDetector; |
| 15 | + delete self.TextDetector; |
| 16 | + |
| 17 | + // background synchronization api |
| 18 | + if (window) { |
| 19 | + delete self.ServiceWorkerRegistration.prototype.sync; |
| 20 | + } |
| 21 | + if (isemulatedsw) { |
| 22 | + delete self.SyncManager; |
| 23 | + delete self.SyncEvent; |
| 24 | + } |
| 25 | + |
| 26 | + // trustedtypes |
| 27 | + delete self.TrustedHTML; |
| 28 | + delete self.TrustedScript; |
| 29 | + delete self.TrustedScriptURL; |
| 30 | + delete self.TrustedTypePolicy; |
| 31 | + delete self.TrustedTypePolicyFactory; |
| 32 | + self.__defineGetter__("trustedTypes", () => undefined); |
| 33 | + |
| 34 | + // whatever this is |
| 35 | + delete self.Navigator.prototype.joinAdInterestGroup; |
| 36 | + |
| 37 | + if (!window) return; |
| 38 | + // DOM specific ones below here |
| 39 | + |
| 40 | + delete self.MediaDevices.prototype.setCaptureHandleConfig; |
| 41 | + |
| 42 | + // 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; |
| 50 | + |
| 51 | + // contact picker api |
| 52 | + delete self.Navigator.prototype.contacts; |
| 53 | + delete self.ContactAddress; |
| 54 | + delete self.ContactManager; |
| 55 | + |
| 56 | + // Idle Detection API |
| 57 | + delete self.IdleDetector; |
| 58 | + |
| 59 | + // 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; |
| 69 | + |
| 70 | + // Window Controls Overlay API |
| 71 | + delete self.WindowControlsOverlay; |
| 72 | + delete self.WindowControlsOverlayGeometryChangeEvent; |
| 73 | + delete self.Navigator.prototype.windowControlsOverlay; |
| 74 | + |
| 75 | + // WebHID API |
| 76 | + delete self.Navigator.prototype.hid; |
| 77 | + delete self.HID; |
| 78 | + delete self.HIDDevice; |
| 79 | + delete self.HIDConnectionEvent; |
| 80 | + delete self.HIDInputReportEvent; |
| 81 | + |
| 82 | + // 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; |
| 90 | +} |
0 commit comments