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";
|
||||
const realf = fetch;
|
||||
export default function (client: ScramjetClient) {
|
||||
client.Proxy("URL.revokeObjectURL", {
|
||||
apply(ctx) {
|
||||
ctx.return(undefined);
|
||||
},
|
||||
});
|
||||
|
||||
// hide the origin from object urls from the page
|
||||
client.Proxy("URL.createObjectURL", {
|
||||
apply(ctx) {
|
||||
const url: string = ctx.call();
|
||||
// additional origin concealer. also you need this for youtube for some fucking reason
|
||||
|
||||
const start = "blob:" + location.origin;
|
||||
if (url.startsWith(start)) {
|
||||
const id = url.substring(start.length);
|
||||
ctx.return("blob:" + client.url.origin + id);
|
||||
if (url.startsWith("blob:")) {
|
||||
ctx.return(rewriteBlob(url, client.meta));
|
||||
} else {
|
||||
ctx.return(url);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
client.Proxy("URL.revokeObjectURL", {
|
||||
apply(ctx) {
|
||||
ctx.args[0] = unrewriteBlob(ctx.args[0]);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
export const {
|
||||
util: { BareClient, ScramjetHeaders, BareMuxConnection },
|
||||
url: { rewriteUrl, unrewriteUrl },
|
||||
url: { rewriteUrl, unrewriteUrl, rewriteBlob, unrewriteBlob },
|
||||
rewrite: {
|
||||
rewriteCss,
|
||||
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 { rewriteHtml, rewriteSrcset } from "./rewriters/html";
|
||||
import { rewriteJs } from "./rewriters/js";
|
||||
|
@ -20,6 +25,8 @@ self.$scramjet.shared = {
|
|||
url: {
|
||||
rewriteUrl,
|
||||
unrewriteUrl,
|
||||
rewriteBlob,
|
||||
unrewriteBlob,
|
||||
},
|
||||
rewrite: {
|
||||
rewriteCss,
|
||||
|
|
9
src/types.d.ts
vendored
9
src/types.d.ts
vendored
|
@ -1,5 +1,10 @@
|
|||
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 {
|
||||
htmlRules,
|
||||
|
@ -57,6 +62,8 @@ declare global {
|
|||
url: {
|
||||
rewriteUrl: typeof rewriteUrl;
|
||||
unrewriteUrl: typeof unrewriteUrl;
|
||||
rewriteBlob: typeof rewriteBlob;
|
||||
unrewriteBlob: typeof unrewriteBlob;
|
||||
};
|
||||
rewrite: {
|
||||
rewriteCss: typeof rewriteCss;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue