N
N
Nadim Zakirov2021-02-06 10:24:56
JavaScript
Nadim Zakirov, 2021-02-06 10:24:56

How to install an unpacked extension in Electron?

I would need an example of installing a browser extension from an arbitrary folder. Can anyone help?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nadim Zakirov, 2021-02-06
@zkrvndm

Found a solution. We put our extension, let's say in the test folder, and then in the main process we execute:

const electron = require('electron');

const app = electron.app;
const BrowserWindow = electron.BrowserWindow;
const session = electron.session;

app.on('ready', async function() {
  
  // Пример установки расширения из папки test внутри проекта:
  var result = await session.defaultSession.loadExtension(__dirname+'\\test');
  console.dir(result);
  
  new_window = new BrowserWindow({
    width: 800,
    height: 600,
    autoHideMenuBar: true
  });
  
  new_window.loadURL('https://yandex.ru');
  
});

app.on('window-all-closed', function() {
  app.quit();
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question