Plugin Loading

This commit is contained in:
smartfridge 2021-05-16 16:29:37 +02:00
parent 8cdd7e15b7
commit 22f8ea1123
6 changed files with 25 additions and 3 deletions

View file

@ -101,9 +101,7 @@ function createWindow() {
// Some APIs can only be used after this event occurs. // Some APIs can only be used after this event occurs.
app.whenReady().then(() => { app.whenReady().then(() => {
createWindow(); createWindow();
session.defaultSession.loadExtension( require("./utils/plugin.js");
`${require("electron").app.getAppPath()}/goosemod/`
);
session session
.fromPartition("some-partition") .fromPartition("some-partition")
.setPermissionRequestHandler((webContents, permission, callback) => { .setPermissionRequestHandler((webContents, permission, callback) => {

23
utils/plugin.js Normal file
View file

@ -0,0 +1,23 @@
const fs = require("fs");
const { app, session, remote } = require("electron");
const pluginFolder = __dirname + "/plugins/";
app.whenReady().then(() => {
fs.readdirSync(pluginFolder).forEach((file) => {
console.log(file);
try {
const manifest = fs.readFileSync(
`${__dirname}/plugins/${file}/manifest.json`,
"utf8"
);
var pluginFile = JSON.parse(manifest);
console.log(pluginFile);
session.defaultSession.loadExtension(`${__dirname}/plugins/${file}/`);
console.log(
`%cLoaded ${pluginFile.name} made by ${pluginFile.author}`,
"color:red"
);
} catch (err) {
console.error(err);
}
});
});

View file

@ -1,6 +1,7 @@
{ {
"name": "GooseMod", "name": "GooseMod",
"version": "1.0", "version": "1.0",
"author": "AAGaming00",
"description": "Loads GooseMod, a discord client modification", "description": "Loads GooseMod, a discord client modification",
"background": { "background": {
"scripts": [ "scripts": [