|
import { rewriteHtml } from "../../shared/rewriters/html";
|
|
import { ScramjetClient } from "../client";
|
|
|
|
export default function (client: ScramjetClient, _self: Self) {
|
|
client.Proxy(
|
|
["Document.prototype.querySelector", "Document.prototype.querySelectorAll"],
|
|
{
|
|
apply(ctx) {
|
|
ctx.args[0] = (ctx.args[0] as string).replace(
|
|
/((?:^|\s)\b\w+\[(?:src|href|data-href))[\^]?(=['"]?(?:https?[:])?\/\/)/,
|
|
"$1*$2"
|
|
);
|
|
},
|
|
}
|
|
);
|
|
|
|
client.Proxy("Document.prototype.write", {
|
|
apply(ctx) {
|
|
if (ctx.args[0])
|
|
try {
|
|
ctx.args[0] = rewriteHtml(
|
|
ctx.args[0],
|
|
client.cookieStore,
|
|
client.meta,
|
|
false
|
|
);
|
|
} catch {}
|
|
},
|
|
});
|
|
|
|
client.Proxy("Document.prototype.writeln", {
|
|
apply(ctx) {
|
|
if (ctx.args[0])
|
|
try {
|
|
ctx.args[0] = rewriteHtml(
|
|
ctx.args[0],
|
|
client.cookieStore,
|
|
client.meta,
|
|
false
|
|
);
|
|
} catch {}
|
|
},
|
|
});
|
|
|
|
client.Proxy("Document.prototype.parseHTMLUnsafe", {
|
|
apply(ctx) {
|
|
if (ctx.args[0])
|
|
try {
|
|
ctx.args[0] = rewriteHtml(
|
|
ctx.args[0],
|
|
client.cookieStore,
|
|
client.meta,
|
|
false
|
|
);
|
|
} catch {}
|
|
},
|
|
});
|
|
}
|
|
|