Disable context isolation (to load ffmpeg wasm)

This commit is contained in:
TC
2021-01-13 21:28:42 +01:00
parent 9ad1dad6df
commit 39c8031cd7
6 changed files with 35 additions and 26 deletions

View File

@ -86,7 +86,9 @@ function createMainWindow() {
backgroundColor: "#000", backgroundColor: "#000",
show: false, show: false,
webPreferences: { 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"), preload: path.join(__dirname, "preload.js"),
nodeIntegrationInSubFrames: true, nodeIntegrationInSubFrames: true,
nativeWindowOpen: true, // window.open return Window object(like in regular browsers), not BrowserWindowProxy nativeWindowOpen: true, // window.open return Window object(like in regular browsers), not BrowserWindowProxy

View File

@ -30,28 +30,30 @@ const reinit = () => {
} }
}; };
contextBridge.exposeInMainWorld("downloader", { // TODO: re-enable once contextIsolation is set to true
download: () => { // contextBridge.exposeInMainWorld("downloader", {
const videoUrl = window.location.href; // download: () => {
global.download = () => {
const videoUrl = window.location.href;
downloadVideoToMP3( downloadVideoToMP3(
videoUrl, videoUrl,
(feedback) => { (feedback) => {
if (!progress) { if (!progress) {
console.warn("Cannot update progress"); console.warn("Cannot update progress");
} else { } else {
progress.innerHTML = feedback; progress.innerHTML = feedback;
} }
}, },
(error) => { (error) => {
triggerAction(CHANNEL, ACTIONS.ERROR, error); triggerAction(CHANNEL, ACTIONS.ERROR, error);
reinit(); reinit();
}, },
reinit, reinit,
pluginOptions pluginOptions
); );
}, };
}); // });
function observeMenu(options) { function observeMenu(options) {
pluginOptions = { ...pluginOptions, ...options }; pluginOptions = { ...pluginOptions, ...options };

View File

@ -4,7 +4,7 @@
tabindex="-1" tabindex="-1"
aria-disabled="false" aria-disabled="false"
aria-selected="false" aria-selected="false"
onclick="downloader.download()" onclick="download()"
> >
<div <div
class="menu-icon yt-icon-container yt-icon ytmusic-toggle-menu-service-item-renderer" class="menu-icon yt-icon-container yt-icon ytmusic-toggle-menu-service-item-renderer"

View File

@ -2,7 +2,7 @@
class="style-scope ytmusic-pivot-bar-renderer navigation-item" class="style-scope ytmusic-pivot-bar-renderer navigation-item"
tab-id="FEmusic_back" tab-id="FEmusic_back"
role="tab" role="tab"
onclick="navigationActions.goToPreviousPage()" onclick="goToPreviousPage()"
> >
<div <div
class="search-icon style-scope ytmusic-search-box" class="search-icon style-scope ytmusic-search-box"

View File

@ -2,7 +2,7 @@
class="style-scope ytmusic-pivot-bar-renderer navigation-item" class="style-scope ytmusic-pivot-bar-renderer navigation-item"
tab-id="FEmusic_next" tab-id="FEmusic_next"
role="tab" role="tab"
onclick="navigationActions.goToNextPage()" onclick="goToNextPage()"
> >
<div <div
class="search-icon style-scope ytmusic-search-box" class="search-icon style-scope ytmusic-search-box"

View File

@ -11,7 +11,12 @@ plugins.forEach(([plugin, options]) => {
const pluginPath = path.join(__dirname, "plugins", plugin, "actions.js"); const pluginPath = path.join(__dirname, "plugins", plugin, "actions.js");
fileExists(pluginPath, () => { fileExists(pluginPath, () => {
const actions = require(pluginPath).actions || {}; const actions = require(pluginPath).actions || {};
contextBridge.exposeInMainWorld(plugin + "Actions", actions);
// TODO: re-enable once contextIsolation is set to true
// contextBridge.exposeInMainWorld(plugin + "Actions", actions);
Object.keys(actions).forEach((actionName) => {
global[actionName] = actions[actionName];
});
}); });
}); });