diff --git a/index.js b/index.js index a083d4d9..10b6f2d9 100644 --- a/index.js +++ b/index.js @@ -86,7 +86,9 @@ function createMainWindow() { backgroundColor: "#000", show: false, webPreferences: { - contextIsolation: true, + // TODO: re-enable contextIsolation once it can work with ffmepg.wasm + // Possible bundling? https://github.com/ffmpegwasm/ffmpeg.wasm/issues/126 + contextIsolation: false, preload: path.join(__dirname, "preload.js"), nodeIntegrationInSubFrames: true, nativeWindowOpen: true, // window.open return Window object(like in regular browsers), not BrowserWindowProxy diff --git a/plugins/downloader/front.js b/plugins/downloader/front.js index d235da65..732fd161 100644 --- a/plugins/downloader/front.js +++ b/plugins/downloader/front.js @@ -30,28 +30,30 @@ const reinit = () => { } }; -contextBridge.exposeInMainWorld("downloader", { - download: () => { - const videoUrl = window.location.href; +// TODO: re-enable once contextIsolation is set to true +// contextBridge.exposeInMainWorld("downloader", { +// download: () => { +global.download = () => { + const videoUrl = window.location.href; - downloadVideoToMP3( - videoUrl, - (feedback) => { - if (!progress) { - console.warn("Cannot update progress"); - } else { - progress.innerHTML = feedback; - } - }, - (error) => { - triggerAction(CHANNEL, ACTIONS.ERROR, error); - reinit(); - }, - reinit, - pluginOptions - ); - }, -}); + downloadVideoToMP3( + videoUrl, + (feedback) => { + if (!progress) { + console.warn("Cannot update progress"); + } else { + progress.innerHTML = feedback; + } + }, + (error) => { + triggerAction(CHANNEL, ACTIONS.ERROR, error); + reinit(); + }, + reinit, + pluginOptions + ); +}; +// }); function observeMenu(options) { pluginOptions = { ...pluginOptions, ...options }; diff --git a/plugins/downloader/templates/download.html b/plugins/downloader/templates/download.html index 7f9ab3ce..138464fb 100644 --- a/plugins/downloader/templates/download.html +++ b/plugins/downloader/templates/download.html @@ -4,7 +4,7 @@ tabindex="-1" aria-disabled="false" aria-selected="false" - onclick="downloader.download()" + onclick="download()" >