Skip to content

Commit

Permalink
Disable context isolation (to load ffmpeg wasm)
Browse files Browse the repository at this point in the history
  • Loading branch information
th-ch committed Jan 13, 2021
1 parent 9ad1dad commit 39c8031
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 26 deletions.
4 changes: 3 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
44 changes: 23 additions & 21 deletions plugins/downloader/front.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand Down
2 changes: 1 addition & 1 deletion plugins/downloader/templates/download.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
tabindex="-1"
aria-disabled="false"
aria-selected="false"
onclick="downloader.download()"
onclick="download()"
>
<div
class="menu-icon yt-icon-container yt-icon ytmusic-toggle-menu-service-item-renderer"
Expand Down
2 changes: 1 addition & 1 deletion plugins/navigation/templates/back.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
class="style-scope ytmusic-pivot-bar-renderer navigation-item"
tab-id="FEmusic_back"
role="tab"
onclick="navigationActions.goToPreviousPage()"
onclick="goToPreviousPage()"
>
<div
class="search-icon style-scope ytmusic-search-box"
Expand Down
2 changes: 1 addition & 1 deletion plugins/navigation/templates/forward.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
class="style-scope ytmusic-pivot-bar-renderer navigation-item"
tab-id="FEmusic_next"
role="tab"
onclick="navigationActions.goToNextPage()"
onclick="goToNextPage()"
>
<div
class="search-icon style-scope ytmusic-search-box"
Expand Down
7 changes: 6 additions & 1 deletion preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ plugins.forEach(([plugin, options]) => {
const pluginPath = path.join(__dirname, "plugins", plugin, "actions.js");
fileExists(pluginPath, () => {
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];
});
});
});

Expand Down

0 comments on commit 39c8031

Please sign in to comment.