mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-13 11:21:46 +00:00
Prepare migration for sandboxing (path.join in preload)
This commit is contained in:
29
preload.js
29
preload.js
@ -1,4 +1,3 @@
|
||||
const path = require("path");
|
||||
require("./providers/front-logger")();
|
||||
const config = require("./config");
|
||||
const { fileExists } = require("./plugins/utils");
|
||||
@ -10,14 +9,26 @@ const plugins = config.plugins.getEnabled();
|
||||
|
||||
let api;
|
||||
|
||||
plugins.forEach(([plugin, options]) => {
|
||||
const preloadPath = path.join(__dirname, "plugins", plugin, "preload.js");
|
||||
plugins.forEach(async ([plugin, options]) => {
|
||||
const preloadPath = await ipcRenderer.invoke(
|
||||
"getPath",
|
||||
__dirname,
|
||||
"plugins",
|
||||
plugin,
|
||||
"preload.js"
|
||||
);
|
||||
fileExists(preloadPath, () => {
|
||||
const run = require(preloadPath);
|
||||
run(options);
|
||||
});
|
||||
|
||||
const actionPath = path.join(__dirname, "plugins", plugin, "actions.js");
|
||||
const actionPath = await ipcRenderer.invoke(
|
||||
"getPath",
|
||||
__dirname,
|
||||
"plugins",
|
||||
plugin,
|
||||
"actions.js"
|
||||
);
|
||||
fileExists(actionPath, () => {
|
||||
const actions = require(actionPath).actions || {};
|
||||
|
||||
@ -30,8 +41,14 @@ plugins.forEach(([plugin, options]) => {
|
||||
});
|
||||
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
plugins.forEach(([plugin, options]) => {
|
||||
const pluginPath = path.join(__dirname, "plugins", plugin, "front.js");
|
||||
plugins.forEach(async ([plugin, options]) => {
|
||||
const pluginPath = await ipcRenderer.invoke(
|
||||
"getPath",
|
||||
__dirname,
|
||||
"plugins",
|
||||
plugin,
|
||||
"front.js"
|
||||
);
|
||||
fileExists(pluginPath, () => {
|
||||
const run = require(pluginPath);
|
||||
run(options);
|
||||
|
||||
Reference in New Issue
Block a user