diff --git a/src/client/dom/open.ts b/src/client/dom/open.ts index 85bc2fc..2644268 100644 --- a/src/client/dom/open.ts +++ b/src/client/dom/open.ts @@ -7,6 +7,9 @@ export default function (client: ScramjetClient) { apply(ctx) { if (ctx.args[0]) ctx.args[0] = rewriteUrl(ctx.args[0], client.meta); + if (["_parent", "_top", "_unfencedTop"].includes(ctx.args[1])) + ctx.args[1] = "_self"; + const realwin = ctx.call(); if (!realwin) return ctx.return(realwin); diff --git a/src/shared/rewriters/html.ts b/src/shared/rewriters/html.ts index 6f29700..3c49ea7 100644 --- a/src/shared/rewriters/html.ts +++ b/src/shared/rewriters/html.ts @@ -186,6 +186,12 @@ export const htmlRules: { fn: (value: string, meta: URLMeta) => rewriteCss(value, meta), style: "*", }, + { + fn: (value: string) => { + if (["_parent", "_top", "_unfencedTop"].includes(value)) return "_self"; + }, + target: ["a", "base"], + }, ]; // i need to add the attributes in during rewriting