mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-11 10:31:47 +00:00
Merge pull request #127 from th-ch/fix-plugins-context-isolation
Fix plugins with context isolation
This commit is contained in:
4
index.js
4
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
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
const { contextBridge } = require("electron");
|
||||
|
||||
const { ElementFromFile, templatePath, triggerAction } = require("../utils");
|
||||
const { ACTIONS, CHANNEL } = require("./actions.js");
|
||||
const { downloadVideoToMP3 } = require("./youtube-dl");
|
||||
@ -28,6 +30,9 @@ const reinit = () => {
|
||||
}
|
||||
};
|
||||
|
||||
// TODO: re-enable once contextIsolation is set to true
|
||||
// contextBridge.exposeInMainWorld("downloader", {
|
||||
// download: () => {
|
||||
global.download = () => {
|
||||
const videoUrl = window.location.href;
|
||||
|
||||
@ -48,6 +53,7 @@ global.download = () => {
|
||||
pluginOptions
|
||||
);
|
||||
};
|
||||
// });
|
||||
|
||||
function observeMenu(options) {
|
||||
pluginOptions = { ...pluginOptions, ...options };
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
const { triggerAction } = require('../utils');
|
||||
const { triggerAction } = require("../utils");
|
||||
|
||||
const CHANNEL = "navigation";
|
||||
const ACTIONS = {
|
||||
NEXT: "next",
|
||||
BACK: 'back',
|
||||
}
|
||||
BACK: "back",
|
||||
};
|
||||
|
||||
function goToNextPage() {
|
||||
triggerAction(CHANNEL, ACTIONS.NEXT);
|
||||
@ -17,8 +17,8 @@ function goToPreviousPage() {
|
||||
module.exports = {
|
||||
CHANNEL: CHANNEL,
|
||||
ACTIONS: ACTIONS,
|
||||
global: {
|
||||
actions: {
|
||||
goToNextPage: goToNextPage,
|
||||
goToPreviousPage: goToPreviousPage,
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
const path = require("path");
|
||||
|
||||
const { remote } = require("electron");
|
||||
const { contextBridge, remote } = require("electron");
|
||||
|
||||
const config = require("./config");
|
||||
const { fileExists } = require("./plugins/utils");
|
||||
@ -10,7 +10,10 @@ const plugins = config.plugins.getEnabled();
|
||||
plugins.forEach(([plugin, options]) => {
|
||||
const pluginPath = path.join(__dirname, "plugins", plugin, "actions.js");
|
||||
fileExists(pluginPath, () => {
|
||||
const actions = require(pluginPath).global || {};
|
||||
const actions = require(pluginPath).actions || {};
|
||||
|
||||
// TODO: re-enable once contextIsolation is set to true
|
||||
// contextBridge.exposeInMainWorld(plugin + "Actions", actions);
|
||||
Object.keys(actions).forEach((actionName) => {
|
||||
global[actionName] = actions[actionName];
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user