Skip to content

Commit

Permalink
proxy Element.prototype.insertAdjacentHTML, rust docs work perfectly …
Browse files Browse the repository at this point in the history
…now.
  • Loading branch information
wearrrrr committed Oct 18, 2024
1 parent 6705d0b commit a748053
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
12 changes: 12 additions & 0 deletions src/client/dom/element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,18 @@ export default function (client: ScramjetClient, self: typeof window) {
},
});

client.Proxy("Element.prototype.insertAdjacentHTML", {
apply(ctx) {
if (ctx.args[1])
ctx.args[1] = rewriteHtml(
ctx.args[1],
client.cookieStore,
client.meta,
true
);
},
})

client.Trap("HTMLIFrameElement.prototype.contentWindow", {
get(ctx) {
const realwin = ctx.get() as Window;
Expand Down
8 changes: 4 additions & 4 deletions src/shared/rewriters/html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,11 +280,11 @@ export function rewriteSrcset(srcset: string, meta: URLMeta) {
return rewrittenUrls.join("");
}

function _base64ToBytes(base64) {
const binString = atob(base64);
// function base64ToBytes(base64) {
// const binString = atob(base64);

return Uint8Array.from(binString, (m) => m.codePointAt(0));
}
// return Uint8Array.from(binString, (m) => m.codePointAt(0));
// }

function bytesToBase64(bytes: Uint8Array) {
const binString = Array.from(bytes, (byte) =>
Expand Down

0 comments on commit a748053

Please sign in to comment.