Some updates!

This commit is contained in:
QuiteAFancyEmerald 2021-11-29 22:02:24 -08:00
parent 47a843bbb8
commit df4ce2ae68
No known key found for this signature in database
GPG key ID: 14E10C9F7DC07318
1412 changed files with 188615 additions and 149532 deletions

View file

@ -0,0 +1,26 @@
function createHistoryRewriter(ctx) {
return function rewriteHistory() {
if (ctx.serviceWorker) return;
if (ctx.window.History.prototype.pushState) {
ctx.window.History.prototype.pushState = new Proxy(ctx.window.History.prototype.pushState, {
apply: (target, that, args) => {
if (args[2]) args[2] = ctx.url.wrap(args[2], ctx.meta);
const ret = Reflect.apply(target, that, args);
ctx.updateLocation();
return ret;
},
});
};
if (ctx.window.History.prototype.replaceState) {
ctx.window.History.prototype.replaceState = new Proxy(ctx.window.History.prototype.replaceState, {
apply: (target, that, args) => {
if (args[2]) args[2] = ctx.url.wrap(args[2], ctx.meta);
const ret = Reflect.apply(target, that, args);
ctx.updateLocation();
return ret;
},
});
};
};
};
module.exports = createHistoryRewriter;