mirror of
https://github.com/shirt-dev/netflix-international.git
synced 2025-06-22 08:36:43 +00:00
initial commit
This commit is contained in:
commit
a7d3a7d8fd
11 changed files with 429 additions and 0 deletions
52
background.js
Normal file
52
background.js
Normal file
|
@ -0,0 +1,52 @@
|
|||
// https://stackoverflow.com/a/45985333
|
||||
function getBrowser() {
|
||||
if (typeof chrome !== "undefined") {
|
||||
if (typeof browser !== "undefined") {
|
||||
return "Firefox";
|
||||
} else {
|
||||
return "Chrome";
|
||||
}
|
||||
} else {
|
||||
return "Edge";
|
||||
}
|
||||
}
|
||||
|
||||
chrome.webRequest.onBeforeRequest.addListener(
|
||||
function (details) {
|
||||
/* Allow our shim to load an untouched copy */
|
||||
if (details.url.endsWith("?no_filter")) {
|
||||
return {};
|
||||
}
|
||||
|
||||
if (getBrowser() == "Chrome") {
|
||||
return {
|
||||
redirectUrl: chrome.extension.getURL("cadmium-playercore-shim.js")
|
||||
};
|
||||
}
|
||||
|
||||
/* Work around funky CORS behaviour on Firefox */
|
||||
else if (getBrowser() == "Firefox") {
|
||||
let filter = browser.webRequest.filterResponseData(details.requestId);
|
||||
let encoder = new TextEncoder();
|
||||
filter.onstop = event => {
|
||||
fetch(browser.extension.getURL("cadmium-playercore-shim.js")).
|
||||
then(response => response.text()).
|
||||
then(text => {
|
||||
filter.write(encoder.encode(text));
|
||||
filter.close();
|
||||
});
|
||||
};
|
||||
return {};
|
||||
}
|
||||
|
||||
else {
|
||||
console.error("Unsupported web browser.");
|
||||
return {};
|
||||
}
|
||||
}, {
|
||||
urls: [
|
||||
"*://assets.nflxext.com/*/ffe/player/html/*",
|
||||
"*://www.assets.nflxext.com/*/ffe/player/html/*"
|
||||
]
|
||||
}, ["blocking"]
|
||||
);
|
Loading…
Add table
Add a link
Reference in a new issue