Skip to content

Commit

Permalink
fix: uncaught exception (1/3) (#580)
Browse files Browse the repository at this point in the history
  • Loading branch information
sereneblue committed May 27, 2024
1 parent 3edd88e commit 50cb7c6
Showing 1 changed file with 42 additions and 34 deletions.
76 changes: 42 additions & 34 deletions src/lib/inject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -525,42 +525,50 @@ class Injector {
spoofContext.Intl.Collator.supportedLocalesOf = _supportedLocalesOfC;
spoofContext.open = function(){
let w = _open.apply(this, Array.from(arguments));
Object.defineProperty(w, 'Date', {
value: spoofContext.Date
});
Object.defineProperty(w.Intl, 'DateTimeFormat', {
value: spoofContext.Intl.DateTimeFormat
});
Object.defineProperty(w, 'screen', {
value: spoofContext.screen
});
Object.defineProperty(w, 'navigator', {
value: spoofContext.navigator
});
Object.defineProperty(w.Element.prototype, 'getBoundingClientRect', {
value: spoofContext.Element.prototype.getBoundingClientRect
});
Object.defineProperty(w.Element.prototype, 'getClientRects', {
value: spoofContext.Element.prototype.getClientRects
});
Object.defineProperty(w.Range.prototype, 'getBoundingClientRect', {
value: spoofContext.Range.prototype.getClientRects
});
Object.defineProperty(w.Range.prototype, 'getClientRects', {
value: spoofContext.Range.prototype.getClientRects
});
let w;
if (arguments.length) {
w = _open.call(this, ...arguments);
} else {
w = _open.call(this);
}
if (w) {
Object.defineProperty(w, 'Date', {
value: spoofContext.Date
});
Object.defineProperty(w.Intl, 'DateTimeFormat', {
value: spoofContext.Intl.DateTimeFormat
});
Object.defineProperty(w, 'screen', {
value: spoofContext.screen
});
Object.defineProperty(w, 'navigator', {
value: spoofContext.navigator
});
Object.defineProperty(w.Element.prototype, 'getBoundingClientRect', {
value: spoofContext.Element.prototype.getBoundingClientRect
});
Object.defineProperty(w.Element.prototype, 'getClientRects', {
value: spoofContext.Element.prototype.getClientRects
});
Object.defineProperty(w.Range.prototype, 'getBoundingClientRect', {
value: spoofContext.Range.prototype.getClientRects
});
Object.defineProperty(w.Range.prototype, 'getClientRects', {
value: spoofContext.Range.prototype.getClientRects
});
}
return w;
}
modifiedAPIs.push([
spoofContext.open, "open"
]);
Expand Down

0 comments on commit 50cb7c6

Please sign in to comment.