Add manifest URL field, reset keys when manifest changes, organize repo, update to Manifest v3 #3
@ -70,8 +70,7 @@ function safeHeaderShellEscape(str) {
|
||||
|
||||
// Intercep network to find manifest
|
||||
function injectManifestInterceptor() {
|
||||
const script = document.createElement("script");
|
||||
script.textContent = `
|
||||
// Execute the interceptor code directly instead of injecting a script
|
||||
(function () {
|
||||
function isProbablyManifest(text = "", contentType = "") {
|
||||
const lowerCT = contentType?.toLowerCase() ?? "";
|
||||
@ -87,8 +86,13 @@ function injectManifestInterceptor() {
|
||||
const isJsonManifest = sample.includes('"playlist"') && sample.includes('"segments"');
|
||||
|
||||
return (
|
||||
isHLSMime || isDASHMime || isSmoothMime ||
|
||||
isHLSKeyword || isDASHKeyword || isSmoothKeyword || isJsonManifest
|
||||
isHLSMime ||
|
||||
isDASHMime ||
|
||||
isSmoothMime ||
|
||||
isHLSKeyword ||
|
||||
isDASHKeyword ||
|
||||
isSmoothKeyword ||
|
||||
isJsonManifest
|
||||
);
|
||||
}
|
||||
|
||||
@ -113,14 +117,24 @@ function injectManifestInterceptor() {
|
||||
});
|
||||
|
||||
const headerFlags = Object.entries(headersObj)
|
||||
.map(([key, val]) => '--add-headers "' + safeHeaderShellEscape(key) + ': ' + safeHeaderShellEscape(val) + '"')
|
||||
.map(
|
||||
([key, val]) =>
|
||||
'--add-headers "' +
|
||||
safeHeaderShellEscape(key) +
|
||||
": " +
|
||||
safeHeaderShellEscape(val) +
|
||||
'"'
|
||||
)
|
||||
.join(" ");
|
||||
|
||||
window.postMessage({
|
||||
window.postMessage(
|
||||
{
|
||||
type: "__MANIFEST_HEADERS__",
|
||||
url,
|
||||
headers: headerFlags
|
||||
}, "*");
|
||||
headers: headerFlags,
|
||||
},
|
||||
"*"
|
||||
);
|
||||
}
|
||||
} catch (e) {}
|
||||
|
||||
@ -146,8 +160,8 @@ function injectManifestInterceptor() {
|
||||
console.log("[Manifest][xhr]", this.__url, contentType);
|
||||
|
||||
const xhrHeaders = {};
|
||||
const rawHeaders = this.getAllResponseHeaders().trim().split(/\\r?\\n/);
|
||||
rawHeaders.forEach(line => {
|
||||
const rawHeaders = this.getAllResponseHeaders().trim().split(/\r?\n/);
|
||||
rawHeaders.forEach((line) => {
|
||||
const parts = line.split(": ");
|
||||
if (parts.length === 2) {
|
||||
xhrHeaders[parts[0]] = parts[1];
|
||||
@ -155,23 +169,30 @@ function injectManifestInterceptor() {
|
||||
});
|
||||
|
||||
const headerFlags = Object.entries(xhrHeaders)
|
||||
.map(([key, val]) => '--add-headers "' + safeHeaderShellEscape(key) + ': ' + safeHeaderShellEscape(val) + '"')
|
||||
.map(
|
||||
([key, val]) =>
|
||||
'--add-headers "' +
|
||||
safeHeaderShellEscape(key) +
|
||||
": " +
|
||||
safeHeaderShellEscape(val) +
|
||||
'"'
|
||||
)
|
||||
.join(" ");
|
||||
|
||||
window.postMessage({
|
||||
window.postMessage(
|
||||
{
|
||||
type: "__MANIFEST_HEADERS__",
|
||||
url: this.__url,
|
||||
headers: headerFlags
|
||||
}, "*");
|
||||
headers: headerFlags,
|
||||
},
|
||||
"*"
|
||||
);
|
||||
}
|
||||
} catch (e) {}
|
||||
});
|
||||
return originalXHRSend.apply(this, arguments);
|
||||
};
|
||||
})();
|
||||
`;
|
||||
document.documentElement.appendChild(script);
|
||||
script.remove();
|
||||
}
|
||||
|
||||
injectManifestInterceptor();
|
||||
|
@ -70,8 +70,7 @@ function safeHeaderShellEscape(str) {
|
||||
|
||||
// Intercep network to find manifest
|
||||
function injectManifestInterceptor() {
|
||||
const script = document.createElement("script");
|
||||
script.textContent = `
|
||||
// Execute the interceptor code directly instead of injecting a script
|
||||
(function () {
|
||||
function isProbablyManifest(text = "", contentType = "") {
|
||||
const lowerCT = contentType?.toLowerCase() ?? "";
|
||||
@ -87,8 +86,13 @@ function injectManifestInterceptor() {
|
||||
const isJsonManifest = sample.includes('"playlist"') && sample.includes('"segments"');
|
||||
|
||||
return (
|
||||
isHLSMime || isDASHMime || isSmoothMime ||
|
||||
isHLSKeyword || isDASHKeyword || isSmoothKeyword || isJsonManifest
|
||||
isHLSMime ||
|
||||
isDASHMime ||
|
||||
isSmoothMime ||
|
||||
isHLSKeyword ||
|
||||
isDASHKeyword ||
|
||||
isSmoothKeyword ||
|
||||
isJsonManifest
|
||||
);
|
||||
}
|
||||
|
||||
@ -113,14 +117,24 @@ function injectManifestInterceptor() {
|
||||
});
|
||||
|
||||
const headerFlags = Object.entries(headersObj)
|
||||
.map(([key, val]) => '--add-headers "' + safeHeaderShellEscape(key) + ': ' + safeHeaderShellEscape(val) + '"')
|
||||
.map(
|
||||
([key, val]) =>
|
||||
'--add-headers "' +
|
||||
safeHeaderShellEscape(key) +
|
||||
": " +
|
||||
safeHeaderShellEscape(val) +
|
||||
'"'
|
||||
)
|
||||
.join(" ");
|
||||
|
||||
window.postMessage({
|
||||
window.postMessage(
|
||||
{
|
||||
type: "__MANIFEST_HEADERS__",
|
||||
url,
|
||||
headers: headerFlags
|
||||
}, "*");
|
||||
headers: headerFlags,
|
||||
},
|
||||
"*"
|
||||
);
|
||||
}
|
||||
} catch (e) {}
|
||||
|
||||
@ -146,8 +160,8 @@ function injectManifestInterceptor() {
|
||||
console.log("[Manifest][xhr]", this.__url, contentType);
|
||||
|
||||
const xhrHeaders = {};
|
||||
const rawHeaders = this.getAllResponseHeaders().trim().split(/\\r?\\n/);
|
||||
rawHeaders.forEach(line => {
|
||||
const rawHeaders = this.getAllResponseHeaders().trim().split(/\r?\n/);
|
||||
rawHeaders.forEach((line) => {
|
||||
const parts = line.split(": ");
|
||||
if (parts.length === 2) {
|
||||
xhrHeaders[parts[0]] = parts[1];
|
||||
@ -155,23 +169,30 @@ function injectManifestInterceptor() {
|
||||
});
|
||||
|
||||
const headerFlags = Object.entries(xhrHeaders)
|
||||
.map(([key, val]) => '--add-headers "' + safeHeaderShellEscape(key) + ': ' + safeHeaderShellEscape(val) + '"')
|
||||
.map(
|
||||
([key, val]) =>
|
||||
'--add-headers "' +
|
||||
safeHeaderShellEscape(key) +
|
||||
": " +
|
||||
safeHeaderShellEscape(val) +
|
||||
'"'
|
||||
)
|
||||
.join(" ");
|
||||
|
||||
window.postMessage({
|
||||
window.postMessage(
|
||||
{
|
||||
type: "__MANIFEST_HEADERS__",
|
||||
url: this.__url,
|
||||
headers: headerFlags
|
||||
}, "*");
|
||||
headers: headerFlags,
|
||||
},
|
||||
"*"
|
||||
);
|
||||
}
|
||||
} catch (e) {}
|
||||
});
|
||||
return originalXHRSend.apply(this, arguments);
|
||||
};
|
||||
})();
|
||||
`;
|
||||
document.documentElement.appendChild(script);
|
||||
script.remove();
|
||||
}
|
||||
|
||||
injectManifestInterceptor();
|
||||
|
Loading…
x
Reference in New Issue
Block a user