mirror of
https://github.com/ION606/browser-chromium.git
synced 2026-05-14 22:26:56 +00:00
added permissions for website
This commit is contained in:
+15
-10
@@ -4,6 +4,7 @@ import fs from 'fs';
|
||||
import { findPath } from './paths.js';
|
||||
import * as tabModule from '../serverJS/tabs_server.js';
|
||||
import loggermod from '../utils/logger.cjs';
|
||||
import { getSitePerms, promptForPerms, setSitePerms } from './dialogue.js';
|
||||
const { logger } = loggermod;
|
||||
|
||||
|
||||
@@ -24,17 +25,19 @@ export default function init(customSession) {
|
||||
ipcMain.on('tab-close', (e, id) => tabModule.closeTab(e, id, customSession));
|
||||
ipcMain.on('tab-new', (e, id, url) => tabModule.addTab(e, id, customSession, url));
|
||||
|
||||
// TODO: add logic here to save/return site perms
|
||||
ipcMain.on('set-site-perms', (e, sitehostname) => console.log(sitehostname));
|
||||
ipcMain.on('get-site-perms', (e, sitehostname) => {
|
||||
console.log(sitehostname);
|
||||
e.sender.send('site-perms', { popups: false });
|
||||
});
|
||||
ipcMain.on('set-site-perms', (e, sitehostname, id, value) => setSitePerms(e, sitehostname, id, value));
|
||||
ipcMain.on('set-site-perms-all', (e, sitehostname, id, value) => setSitePerms(e, sitehostname, id, value, true));
|
||||
ipcMain.on('get-site-perms', getSitePerms);
|
||||
ipcMain.on('prompt-terms', (e, sitehostname) => promptForPerms(tabModule.getCurrentWindow(), sitehostname));
|
||||
|
||||
// TODO: make an actual settings page
|
||||
ipcMain.on('open-settings', async (e) => promptForPerms(tabModule.getCurrentWindow(), await tabModule.getCurrentTab()?.webContents.executeJavaScript('window.location.hostname')));
|
||||
}
|
||||
|
||||
|
||||
const renderer = (fs.readFileSync(await findPath('renderer.js'), 'utf-8')),
|
||||
optimize = (fs.readFileSync(await findPath('optimize.js'), 'utf-8'));
|
||||
optimize = (fs.readFileSync(await findPath('optimize.js'), 'utf-8')),
|
||||
adblock = (fs.readFileSync(await findPath('clientAdBlock.js'), 'utf-8'))
|
||||
|
||||
|
||||
/**
|
||||
@@ -42,9 +45,11 @@ const renderer = (fs.readFileSync(await findPath('renderer.js'), 'utf-8')),
|
||||
*/
|
||||
export async function startinject(mainWindow, uid) {
|
||||
// execute the script in the renderer process
|
||||
mainWindow.webContents.executeJavaScript(renderer);
|
||||
mainWindow.webContents.executeJavaScript(optimize);
|
||||
// mainWindow.webContents.executeJavaScript(tabs);
|
||||
await mainWindow.webContents.executeJavaScript(renderer);
|
||||
await mainWindow.webContents.executeJavaScript(optimize);
|
||||
await mainWindow.webContents.executeJavaScript(adblock);
|
||||
const perms = (await getSitePerms(null, mainWindow.webContents.getURL())) || {};
|
||||
await mainWindow.webContents.executeJavaScript(`setupAdBlock(${JSON.stringify(perms)})`);
|
||||
|
||||
const title = await mainWindow.webContents.executeJavaScript('document.title');
|
||||
addHistory(uid, mainWindow.webContents.getURL(), 200, title);
|
||||
|
||||
Reference in New Issue
Block a user