mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-10 10:11:46 +00:00
36 lines
1.0 KiB
JavaScript
36 lines
1.0 KiB
JavaScript
const path = require("path");
|
|
|
|
const { contextBridge, remote } = require("electron");
|
|
|
|
const config = require("./config");
|
|
const { fileExists } = require("./plugins/utils");
|
|
|
|
const plugins = config.plugins.getEnabled();
|
|
|
|
plugins.forEach(([plugin, options]) => {
|
|
const pluginPath = path.join(__dirname, "plugins", plugin, "actions.js");
|
|
fileExists(pluginPath, () => {
|
|
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];
|
|
});
|
|
});
|
|
});
|
|
|
|
document.addEventListener("DOMContentLoaded", () => {
|
|
plugins.forEach(([plugin, options]) => {
|
|
const pluginPath = path.join(__dirname, "plugins", plugin, "front.js");
|
|
fileExists(pluginPath, () => {
|
|
const run = require(pluginPath);
|
|
run(options);
|
|
});
|
|
});
|
|
|
|
// Add action for reloading
|
|
global.reload = () =>
|
|
remote.getCurrentWindow().webContents.loadURL(config.get("url"));
|
|
});
|