|
1 | 1 | import * as utils from "./utils"; |
2 | 2 | import { isMessage } from "./messages"; |
| 3 | +import { Options } from "./common"; |
3 | 4 |
|
4 | 5 | async function contentScriptRegistered() { |
5 | 6 | const matchingScripts = await utils.scripting.getRegisteredContentScripts({ |
@@ -61,11 +62,11 @@ async function isHeaderConditionSupported() { |
61 | 62 | } |
62 | 63 | } |
63 | 64 |
|
64 | | -async function enableSWFTakeover() { |
| 65 | +async function enableSWFTakeover(opt: Options | null = null) { |
| 66 | + const options = opt || (await utils.getOptions()); |
65 | 67 | // Checks if the responseHeaders condition is supported and not behind a disabled flag. |
66 | 68 | if (utils.declarativeNetRequest && (await isHeaderConditionSupported())) { |
67 | | - const { ruffleEnable } = await utils.getOptions(); |
68 | | - if (ruffleEnable) { |
| 69 | + if (options.ruffleEnable) { |
69 | 70 | const playerPage = utils.runtime.getURL("/player.html"); |
70 | 71 | const rules = [ |
71 | 72 | { |
@@ -163,10 +164,10 @@ async function disableSWFTakeover() { |
163 | 164 | } |
164 | 165 | } |
165 | 166 |
|
166 | | -async function enable() { |
167 | | - const { swfTakeover } = await utils.getOptions(); |
168 | | - if (swfTakeover) { |
169 | | - await enableSWFTakeover(); |
| 167 | +async function enable(opt: Options | null = null) { |
| 168 | + const options = opt || (await utils.getOptions()); |
| 169 | + if (options.swfTakeover) { |
| 170 | + await enableSWFTakeover(options); |
170 | 171 | } |
171 | 172 | if ( |
172 | 173 | !utils.scripting || |
@@ -261,9 +262,9 @@ function onMessage( |
261 | 262 | } |
262 | 263 |
|
263 | 264 | (async () => { |
264 | | - const { ruffleEnable } = await utils.getOptions(); |
265 | | - if (ruffleEnable) { |
266 | | - await enable(); |
| 265 | + const options = await utils.getOptions(); |
| 266 | + if (options.ruffleEnable) { |
| 267 | + await enable(options); |
267 | 268 | } |
268 | 269 | })(); |
269 | 270 |
|
|
0 commit comments