playstore bypass support

This commit is contained in:
Toshit Chawda 2024-08-13 21:08:36 -07:00
parent 1999996b2a
commit 1d10e44ba0
No known key found for this signature in database
GPG key ID: 91480ED99E2B3D9D
2 changed files with 6 additions and 5 deletions

View file

@ -25,8 +25,7 @@ const cspHeaders = [
const urlHeaders = ["location", "content-location", "referer"]; const urlHeaders = ["location", "content-location", "referer"];
function rewriteLinkHeader(link: string, origin?: URL) { function rewriteLinkHeader(link: string, origin?: URL) {
return link return link.replace(/<(.*)>/gi, (match) => encodeUrl(match, origin));
.replace(/<(.*)>/gi, (match) => encodeUrl(match, origin));
} }
export function rewriteHeaders(rawHeaders: BareHeaders, origin?: URL) { export function rewriteHeaders(rawHeaders: BareHeaders, origin?: URL) {
@ -49,7 +48,7 @@ export function rewriteHeaders(rawHeaders: BareHeaders, origin?: URL) {
}); });
if (typeof headers["link"] === "string") { if (typeof headers["link"] === "string") {
headers["link"] = rewriteLinkHeader(headers["link"], origin) headers["link"] = rewriteLinkHeader(headers["link"], origin);
} else if (Array.isArray(headers["link"])) { } else if (Array.isArray(headers["link"])) {
headers["link"] = headers["link"].map((link) => headers["link"] = headers["link"].map((link) =>
rewriteLinkHeader(link, origin) rewriteLinkHeader(link, origin)

View file

@ -20,7 +20,8 @@ Error.stackTraceLimit = 50;
global.rws = rewriteJs; global.rws = rewriteJs;
export function rewriteJs(js: string | ArrayBuffer, origin?: URL) { export function rewriteJs(js: string | ArrayBuffer, origin?: URL) {
if ("window" in globalThis) origin ??= new URL(decodeUrl(location.href)); if ("window" in globalThis)
origin = origin ?? new URL(decodeUrl(location.href));
const before = performance.now(); const before = performance.now();
if (typeof js === "string") { if (typeof js === "string") {
@ -48,7 +49,8 @@ export function rewriteJs(js: string | ArrayBuffer, origin?: URL) {
// //
// if you can ensure all the preconditions are met this is faster than full rewrites // if you can ensure all the preconditions are met this is faster than full rewrites
export function rewriteJsNaiive(js: string | ArrayBuffer, origin?: URL) { export function rewriteJsNaiive(js: string | ArrayBuffer, origin?: URL) {
if ("window" in globalThis) origin ??= new URL(decodeUrl(location.href)); if ("window" in globalThis)
origin = origin ?? new URL(decodeUrl(location.href));
if (typeof js !== "string") { if (typeof js !== "string") {
js = new TextDecoder().decode(js); js = new TextDecoder().decode(js);