This repository has been archived by the owner on Sep 16, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #104 from soundofspace/feat(browser-emulator)--mor…
…e-improvements Feat(browser-emulator): Migrating away from proxies, lots of extra improvements and enabling TS strict mode
- Loading branch information
Showing
39 changed files
with
1,435 additions
and
744 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 12 additions & 5 deletions
17
plugins/default-browser-emulator/injected-scripts/Document.prototype.cookie.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,18 @@ | ||
const triggerName = args.callbackName; | ||
export type Args = { | ||
callbackName: string; | ||
}; | ||
const typedArgs = args as Args; | ||
const triggerName = typedArgs.callbackName; | ||
|
||
if (!self[triggerName]) throw new Error('No cookie trigger'); | ||
const cookieTrigger = ((self[triggerName] as unknown) as Function).bind(self); | ||
const cookieTrigger = (self[triggerName] as unknown as Function).bind(self); | ||
|
||
delete self[triggerName]; | ||
|
||
proxySetter(Document.prototype, 'cookie', (target, thisArg, cookie) => { | ||
cookieTrigger(JSON.stringify({ cookie, origin: self.location.origin })); | ||
return ProxyOverride.callOriginal; | ||
replaceSetter(Document.prototype, 'cookie', (target, thisArg, argArray) => { | ||
const cookie = argArray.at(0); | ||
if (cookie) { | ||
cookieTrigger(JSON.stringify({ cookie, origin: self.location.origin })); | ||
} | ||
return ReflectCached.apply(target, thisArg, argArray!); | ||
}); |
8 changes: 3 additions & 5 deletions
8
plugins/default-browser-emulator/injected-scripts/JSON.stringify.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,7 @@ | ||
proxyFunction(JSON, 'stringify', (target, thisArg, argArray) => { | ||
argArray[1] = null; | ||
argArray[2] = 2; | ||
export type Args = never; | ||
|
||
const result = target.apply(thisArg, argArray); | ||
replaceFunction(JSON, 'stringify', (target, thisArg, argArray) => { | ||
const result = ReflectCached.apply(target, thisArg, [argArray.at(0), null, 2]); | ||
console.log(result); | ||
|
||
return result; | ||
}); |
14 changes: 10 additions & 4 deletions
14
plugins/default-browser-emulator/injected-scripts/MediaDevices.prototype.enumerateDevices.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 8 additions & 3 deletions
11
plugins/default-browser-emulator/injected-scripts/RTCRtpSender.getCapabilities.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.