diff --git a/README.md b/README.md index 7ebecf7..a90c049 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Features: - [x] Small window on your menubar (or isolated window) - [x] Desktop notification - [x] Customizable shortcut keybinds -- [ ] Multi-account +- [ ] Multi-account (switching among accounts) Mastodon is an open source project. So if you want to make a new UI, you can just fork the project, implement your favorite UI and host it on your place. Then you can participate Mastodon networks from it. diff --git a/main/app.ts b/main/app.ts index 04a2c4e..2fb82b2 100644 --- a/main/app.ts +++ b/main/app.ts @@ -1,5 +1,5 @@ import * as path from 'path'; -import {app, BrowserWindow, globalShortcut, Tray, shell} from 'electron'; +import {app, BrowserWindow, globalShortcut, Tray, shell, dialog} from 'electron'; import windowState = require('electron-window-state'); import * as menubar from 'menubar'; import log from './log'; @@ -23,6 +23,7 @@ export class App { } open() { + this.win.loadURL(`https://${this.account.host}${this.account.default_page}`); this.win.webContents.on('will-navigate', (e, url) => { if (!url.startsWith(`https://${this.account.host}`)) { e.preventDefault(); @@ -33,7 +34,23 @@ export class App { e.preventDefault(); shell.openExternal(url); }); - this.win.loadURL(`https://${this.account.host}${this.account.default_page}`); + this.win.webContents.session.setPermissionRequestHandler((contents, permission, callback) => { + if (permission !== 'geolocation' && permission !== 'media') { + // Granted + callback(true); + return; + } + + dialog.showMessageBox({ + type: 'question', + buttons: ['Accept', 'Reject'], + message: `Permission '${permission}' is requested by ${contents.getURL()}`, + detail: "Please choose one of 'Accept' or 'Reject'", + }, (buttonIndex: number) => { + const granted = buttonIndex === 0; + callback(granted); + }); + }); this.win.show(); } }