extension: Fix 4399 CORS and Flash detection issue (close #13943) (#16750)

Co-authored-by: Zhentao Lu <zhentaolu@microsoft.com>
This commit is contained in:
riku 2024-06-21 23:05:53 +08:00 committed by GitHub
parent dc03f541db
commit 036839fb1f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 45 additions and 0 deletions

View File

@ -0,0 +1,21 @@
[
{
"id": 1,
"priority": 1,
"condition": {
"initiatorDomains": ["4399.com"],
"urlFilter": "|*.swf",
"resourceTypes": ["xmlhttprequest"]
},
"action": {
"type": "modifyHeaders",
"responseHeaders": [
{
"header": "Access-Control-Allow-Origin",
"operation": "set",
"value": "https://www.4399.com"
}
]
}
}
]

View File

@ -28,6 +28,12 @@
"js": ["dist/content.js"], "js": ["dist/content.js"],
"all_frames": true, "all_frames": true,
"run_at": "document_start", "run_at": "document_start",
},
{
"matches": ["https://www.4399.com/flash/*"],
"js": ["dist/siteContentScript4399.js"],
"world": "MAIN",
"run_at": "document_start",
} }
], ],
@ -50,11 +56,19 @@
"permissions": [ "permissions": [
"storage", "storage",
"scripting", "scripting",
"declarativeNetRequest",
], ],
"web_accessible_resources": [{ "web_accessible_resources": [{
"resources": ["*"], "resources": ["*"],
"matches": ["<all_urls>"], "matches": ["<all_urls>"],
}], }],
"declarative_net_request": {
"rule_resources": [{
"id": "4399_rules",
"enabled": true,
"path": "dist/4399_rules.json"
}]
},
// Chrome runs the extension in a single shared process by default, // Chrome runs the extension in a single shared process by default,
// which prevents extension pages from loading in Incognito tabs // which prevents extension pages from loading in Incognito tabs

View File

@ -0,0 +1,8 @@
try {
Object.defineProperty(window, "showBlockFlash", {
value: () => {},
writable: false,
});
} catch (e) {
// Ignore.
}

View File

@ -85,6 +85,7 @@ export default function (/** @type {Record<string, any>} */ env, _argv) {
background: "./src/background.ts", background: "./src/background.ts",
player: "./src/player.ts", player: "./src/player.ts",
pluginPolyfill: "./src/plugin-polyfill.ts", pluginPolyfill: "./src/plugin-polyfill.ts",
siteContentScript4399: "./src/4399-content-script.ts",
}, },
output: { output: {
path: url.fileURLToPath(new URL("assets/dist/", import.meta.url)), path: url.fileURLToPath(new URL("assets/dist/", import.meta.url)),
@ -130,6 +131,7 @@ export default function (/** @type {Record<string, any>} */ env, _argv) {
}, },
{ from: "LICENSE*" }, { from: "LICENSE*" },
{ from: "README.md" }, { from: "README.md" },
{ from: "4399_rules.json" },
], ],
}), }),
], ],