mirror of
https://github.com/notion-enhancer/notion-enhancer.git
synced 2025-04-05 13:19:03 +00:00
remove extra buttons from macOS
This commit is contained in:
parent
96571f2b31
commit
31ccd13ced
@ -22,7 +22,8 @@ require('electron').remote.getGlobal('setTimeout')(() => {
|
|||||||
tray: false,
|
tray: false,
|
||||||
theme: false,
|
theme: false,
|
||||||
},
|
},
|
||||||
});
|
}),
|
||||||
|
isMac = process.platform === 'darwin';
|
||||||
|
|
||||||
const intervalID = setInterval(injection, 100);
|
const intervalID = setInterval(injection, 100);
|
||||||
function injection() {
|
function injection() {
|
||||||
@ -52,10 +53,13 @@ require('electron').remote.getGlobal('setTimeout')(() => {
|
|||||||
buttons.className = 'window-buttons-area';
|
buttons.className = 'window-buttons-area';
|
||||||
buttons.innerHTML = `
|
buttons.innerHTML = `
|
||||||
<button class="window-button btn-alwaysontop"></button>
|
<button class="window-button btn-alwaysontop"></button>
|
||||||
<button class="window-button btn-minimize"></button>
|
|
||||||
<button class="window-button btn-maximize"></button>
|
|
||||||
<button class="window-button btn-close"></button>
|
|
||||||
`;
|
`;
|
||||||
|
if (!isMac)
|
||||||
|
buttons.innerHTML += `
|
||||||
|
<button class="window-button btn-minimize"></button>
|
||||||
|
<button class="window-button btn-maximize"></button>
|
||||||
|
<button class="window-button btn-close"></button>
|
||||||
|
`;
|
||||||
document
|
document
|
||||||
.querySelector('.notion-topbar > div[style*="display: flex"]')
|
.querySelector('.notion-topbar > div[style*="display: flex"]')
|
||||||
.appendChild(buttons);
|
.appendChild(buttons);
|
||||||
@ -96,12 +100,13 @@ require('electron').remote.getGlobal('setTimeout')(() => {
|
|||||||
: appwindow.maximize();
|
: appwindow.maximize();
|
||||||
this.innerHTML = button_icons.maximize();
|
this.innerHTML = button_icons.maximize();
|
||||||
},
|
},
|
||||||
close() {
|
close(event = null) {
|
||||||
if (
|
if (
|
||||||
store.tray &&
|
store.tray &&
|
||||||
require('electron').remote.BrowserWindow.getAllWindows().length ===
|
require('electron').remote.BrowserWindow.getAllWindows().length ===
|
||||||
1
|
1
|
||||||
) {
|
) {
|
||||||
|
if (event) event.preventDefault();
|
||||||
appwindow.hide();
|
appwindow.hide();
|
||||||
} else appwindow.close();
|
} else appwindow.close();
|
||||||
},
|
},
|
||||||
@ -116,18 +121,21 @@ require('electron').remote.getGlobal('setTimeout')(() => {
|
|||||||
button_elements.alwaysontop.innerHTML = button_icons.alwaysontop();
|
button_elements.alwaysontop.innerHTML = button_icons.alwaysontop();
|
||||||
button_elements.alwaysontop.onclick = button_actions.alwaysontop;
|
button_elements.alwaysontop.onclick = button_actions.alwaysontop;
|
||||||
|
|
||||||
button_elements.minimize.innerHTML = button_icons.minimize();
|
if (!isMac) {
|
||||||
button_elements.minimize.onclick = button_actions.minimize;
|
button_elements.minimize.innerHTML = button_icons.minimize();
|
||||||
|
button_elements.minimize.onclick = button_actions.minimize;
|
||||||
|
|
||||||
button_elements.maximize.innerHTML = button_icons.maximize();
|
button_elements.maximize.innerHTML = button_icons.maximize();
|
||||||
button_elements.maximize.onclick = button_actions.maximize;
|
button_elements.maximize.onclick = button_actions.maximize;
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
if (button_elements.maximize.innerHTML != button_icons.maximize())
|
if (button_elements.maximize.innerHTML != button_icons.maximize())
|
||||||
button_elements.maximize.innerHTML = button_icons.maximize();
|
button_elements.maximize.innerHTML = button_icons.maximize();
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
|
||||||
button_elements.close.innerHTML = button_icons.close();
|
button_elements.close.innerHTML = button_icons.close();
|
||||||
button_elements.close.onclick = button_actions.close;
|
button_elements.close.onclick = button_actions.close;
|
||||||
|
}
|
||||||
|
appwindow.on('close', button_actions.close);
|
||||||
|
|
||||||
/* hotkey: reload window */
|
/* hotkey: reload window */
|
||||||
document.defaultView.addEventListener(
|
document.defaultView.addEventListener(
|
||||||
|
@ -36,7 +36,7 @@ function enhancements() {
|
|||||||
const contextMenu = Menu.buildFromTemplate([
|
const contextMenu = Menu.buildFromTemplate([
|
||||||
{
|
{
|
||||||
id: 'startup',
|
id: 'startup',
|
||||||
label: 'run on startup',
|
label: 'Run on Startup',
|
||||||
type: 'checkbox',
|
type: 'checkbox',
|
||||||
checked: electron_1.app.getLoginItemSettings().openAtLogin,
|
checked: electron_1.app.getLoginItemSettings().openAtLogin,
|
||||||
click: () => {
|
click: () => {
|
||||||
@ -48,7 +48,7 @@ function enhancements() {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'openhidden',
|
id: 'openhidden',
|
||||||
label: 'hide on open',
|
label: 'Hide on Open',
|
||||||
type: 'checkbox',
|
type: 'checkbox',
|
||||||
checked: store.openhidden,
|
checked: store.openhidden,
|
||||||
click: () => {
|
click: () => {
|
||||||
@ -58,7 +58,7 @@ function enhancements() {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'maximized',
|
id: 'maximized',
|
||||||
label: 'open maximised',
|
label: 'Open Maximised',
|
||||||
type: 'checkbox',
|
type: 'checkbox',
|
||||||
checked: store.maximized,
|
checked: store.maximized,
|
||||||
click: () => {
|
click: () => {
|
||||||
@ -68,7 +68,7 @@ function enhancements() {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'tray',
|
id: 'tray',
|
||||||
label: 'close to tray',
|
label: 'Close to Tray',
|
||||||
type: 'checkbox',
|
type: 'checkbox',
|
||||||
checked: store.tray,
|
checked: store.tray,
|
||||||
click: () => {
|
click: () => {
|
||||||
@ -78,7 +78,7 @@ function enhancements() {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'theme',
|
id: 'theme',
|
||||||
label: 'load theme.css',
|
label: 'Load Custom Theme',
|
||||||
type: 'checkbox',
|
type: 'checkbox',
|
||||||
checked: store.theme,
|
checked: store.theme,
|
||||||
click: () => {
|
click: () => {
|
||||||
@ -91,12 +91,12 @@ function enhancements() {
|
|||||||
type: 'separator',
|
type: 'separator',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: '(x) quit',
|
label: 'Quit',
|
||||||
role: 'quit',
|
role: 'quit',
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
tray.setContextMenu(contextMenu);
|
tray.setContextMenu(contextMenu);
|
||||||
tray.setToolTip('notion enhancements');
|
tray.setToolTip('Notion Enhancements');
|
||||||
|
|
||||||
function showWindows() {
|
function showWindows() {
|
||||||
const windows = electron_1.BrowserWindow.getAllWindows();
|
const windows = electron_1.BrowserWindow.getAllWindows();
|
||||||
|
Loading…
Reference in New Issue
Block a user