Skip to content

Instantly share code, notes, and snippets.

@xbenjii
Created February 12, 2016 13:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xbenjii/c7b6bdc618bd19852b5c to your computer and use it in GitHub Desktop.
Save xbenjii/c7b6bdc618bd19852b5c to your computer and use it in GitHub Desktop.
fs.readdir(`./plugins`, (err, plugins) => {
if(err) {
console.log(`Error reading plugins folder: ${err}`);
}
webview.addEventListener('did-navigate', (event) => {
plugins.forEach((plugin) => {
const pluginSettings = require(`../plugins/${plugin}/settings.json`);
fs.readFile(`./plugins/${plugin}/plugin.js`, 'utf8', (err, code) => {
if(err) {
console.log(`Error loading plugin (${plugin}): ${err}`);
}
if(event.url.match(new RegExp(pluginSettings.page))) {
webview.executeJavaScript(code);
}
});
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment