mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-13 22:40:01 -04:00
24 lines
596 B
TypeScript
24 lines
596 B
TypeScript
import { decodeUrl, encodeUrl, rewriteHeaders } from "../../../shared";
|
|
|
|
export default function (client, self) {
|
|
client.Proxy("XMLHttpRequest.prototype.open", {
|
|
apply(ctx) {
|
|
if (ctx.args[1]) ctx.args[1] = encodeUrl(ctx.args[1]);
|
|
},
|
|
});
|
|
|
|
client.Proxy("XMLHttpRequest.prototype.setRequestHeader", {
|
|
apply(ctx) {
|
|
let headerObject = Object.fromEntries([ctx.args]);
|
|
headerObject = rewriteHeaders(headerObject);
|
|
|
|
ctx.args = Object.entries(headerObject)[0];
|
|
},
|
|
});
|
|
|
|
client.Trap("XMLHttpRequest.prototype.responseURL", {
|
|
get(ctx) {
|
|
return decodeUrl(ctx.get());
|
|
},
|
|
});
|
|
}
|