mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-14 06:50:01 -04:00
revokeobjecturl
This commit is contained in:
parent
e1d654472e
commit
dc0a2c6d12
4 changed files with 27 additions and 16 deletions
|
@ -1,24 +1,21 @@
|
||||||
|
import { rewriteBlob, unrewriteBlob } from "../../shared";
|
||||||
import { ScramjetClient } from "../client";
|
import { ScramjetClient } from "../client";
|
||||||
const realf = fetch;
|
|
||||||
export default function (client: ScramjetClient) {
|
export default function (client: ScramjetClient) {
|
||||||
client.Proxy("URL.revokeObjectURL", {
|
// hide the origin from object urls from the page
|
||||||
apply(ctx) {
|
|
||||||
ctx.return(undefined);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
client.Proxy("URL.createObjectURL", {
|
client.Proxy("URL.createObjectURL", {
|
||||||
apply(ctx) {
|
apply(ctx) {
|
||||||
const url: string = ctx.call();
|
const url: string = ctx.call();
|
||||||
// additional origin concealer. also you need this for youtube for some fucking reason
|
if (url.startsWith("blob:")) {
|
||||||
|
ctx.return(rewriteBlob(url, client.meta));
|
||||||
const start = "blob:" + location.origin;
|
|
||||||
if (url.startsWith(start)) {
|
|
||||||
const id = url.substring(start.length);
|
|
||||||
ctx.return("blob:" + client.url.origin + id);
|
|
||||||
} else {
|
} else {
|
||||||
ctx.return(url);
|
ctx.return(url);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
client.Proxy("URL.revokeObjectURL", {
|
||||||
|
apply(ctx) {
|
||||||
|
ctx.args[0] = unrewriteBlob(ctx.args[0]);
|
||||||
|
},
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
export const {
|
export const {
|
||||||
util: { BareClient, ScramjetHeaders, BareMuxConnection },
|
util: { BareClient, ScramjetHeaders, BareMuxConnection },
|
||||||
url: { rewriteUrl, unrewriteUrl },
|
url: { rewriteUrl, unrewriteUrl, rewriteBlob, unrewriteBlob },
|
||||||
rewrite: {
|
rewrite: {
|
||||||
rewriteCss,
|
rewriteCss,
|
||||||
unrewriteCss,
|
unrewriteCss,
|
||||||
|
|
|
@ -1,4 +1,9 @@
|
||||||
import { rewriteUrl, unrewriteUrl } from "./rewriters/url";
|
import {
|
||||||
|
rewriteUrl,
|
||||||
|
unrewriteUrl,
|
||||||
|
rewriteBlob,
|
||||||
|
unrewriteBlob,
|
||||||
|
} from "./rewriters/url";
|
||||||
import { rewriteCss, unrewriteCss } from "./rewriters/css";
|
import { rewriteCss, unrewriteCss } from "./rewriters/css";
|
||||||
import { rewriteHtml, rewriteSrcset } from "./rewriters/html";
|
import { rewriteHtml, rewriteSrcset } from "./rewriters/html";
|
||||||
import { rewriteJs } from "./rewriters/js";
|
import { rewriteJs } from "./rewriters/js";
|
||||||
|
@ -20,6 +25,8 @@ self.$scramjet.shared = {
|
||||||
url: {
|
url: {
|
||||||
rewriteUrl,
|
rewriteUrl,
|
||||||
unrewriteUrl,
|
unrewriteUrl,
|
||||||
|
rewriteBlob,
|
||||||
|
unrewriteBlob,
|
||||||
},
|
},
|
||||||
rewrite: {
|
rewrite: {
|
||||||
rewriteCss,
|
rewriteCss,
|
||||||
|
|
9
src/types.d.ts
vendored
9
src/types.d.ts
vendored
|
@ -1,5 +1,10 @@
|
||||||
import { ScramjetController } from "./controller/index";
|
import { ScramjetController } from "./controller/index";
|
||||||
import { rewriteUrl, unrewriteUrl } from "./shared/rewriters/url";
|
import {
|
||||||
|
rewriteBlob,
|
||||||
|
rewriteUrl,
|
||||||
|
unrewriteBlob,
|
||||||
|
unrewriteUrl,
|
||||||
|
} from "./shared/rewriters/url";
|
||||||
import { rewriteCss, unrewriteCss } from "./shared/rewriters/css";
|
import { rewriteCss, unrewriteCss } from "./shared/rewriters/css";
|
||||||
import {
|
import {
|
||||||
htmlRules,
|
htmlRules,
|
||||||
|
@ -57,6 +62,8 @@ declare global {
|
||||||
url: {
|
url: {
|
||||||
rewriteUrl: typeof rewriteUrl;
|
rewriteUrl: typeof rewriteUrl;
|
||||||
unrewriteUrl: typeof unrewriteUrl;
|
unrewriteUrl: typeof unrewriteUrl;
|
||||||
|
rewriteBlob: typeof rewriteBlob;
|
||||||
|
unrewriteBlob: typeof unrewriteBlob;
|
||||||
};
|
};
|
||||||
rewrite: {
|
rewrite: {
|
||||||
rewriteCss: typeof rewriteCss;
|
rewriteCss: typeof rewriteCss;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue