mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-14 06:50:01 -04:00
rewrite _top in open target
This commit is contained in:
parent
db573d341c
commit
c5fab0b66b
2 changed files with 6 additions and 1 deletions
|
@ -6,7 +6,10 @@ export default function (client: ScramjetClient) {
|
|||
apply(ctx) {
|
||||
if (ctx.args[0]) ctx.args[0] = encodeUrl(ctx.args[0]);
|
||||
|
||||
const realwin = ctx.fn.apply(this, ctx.args);
|
||||
if (["_parent", "_top", "_unfencedTop"].includes(ctx.args[1]))
|
||||
ctx.args[1] = "_self";
|
||||
|
||||
const realwin = ctx.fn.apply(ctx.this, ctx.args);
|
||||
|
||||
if (ScramjetClient.SCRAMJET in realwin.self) {
|
||||
return ctx.return(realwin.self[ScramjetClient.SCRAMJET].windowProxy);
|
||||
|
|
|
@ -55,6 +55,8 @@ function traverseParsedHtml(node, origin?: URL) {
|
|||
"video",
|
||||
].includes(node.name)
|
||||
) {
|
||||
if (["_parent", "_top", "_unfencedTop"].includes(node.attribs["target"]))
|
||||
node.attribs["target"] = "_self";
|
||||
const value = node.attribs[urlAttr];
|
||||
node.attribs[`data-${urlAttr}`] = value;
|
||||
node.attribs[urlAttr] = encodeUrl(value, origin);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue