From 03113659e762326ac9f7b4e681e20b2566969572 Mon Sep 17 00:00:00 2001
From: dragonwocky
Date: Mon, 30 Mar 2020 11:49:50 +1100
Subject: [PATCH] add F5 as a window reload hotkey
---
CHANGELOG.md | 3 ++-
README.md | 11 ++++++-----
customiser.py | 4 ++--
docs/changelog.html | 3 ++-
docs/index.html | 12 ++++++++----
resources/preload.js | 14 +++++++++++---
6 files changed, 31 insertions(+), 16 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index cb7a479..2f03387 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,7 +5,8 @@ but can still easily be enabled by following instructions in the [docs](README.m
### v0.5.0 (wip)
-- new: running from the WSL.
+- new: running from the wsl.
+- new: reload window with f5.
- improved: code has been refactored and cleaned up,
inc. file renaming.
- bugfix: un-break having multiple notion windows open.
diff --git a/README.md b/README.md
index e8a9c85..c422178 100644
--- a/README.md
+++ b/README.md
@@ -60,10 +60,11 @@ to add these to the web version, copy lines 43 - 87 from `user.css` into your cs
### hotkey
-by default, `ctrl+shift+a` (will hide/show all notion windows to/from the tray).
-
-to set your own, open `customiser.py` and change line 16 (`hotkey = 'ctrl+shift+a'`)
-to your preference. you will need to run or re-run `customiser.py` afterwards.
+- **toggle all notion windows to/from the tray**: `CmdOrCtrl+Shift+A` by default.
+ to set your own, open `customiser.py` and change line 16 (`hotkey = 'ctrl+shift+a'`)
+ to your preference. you will need to run or re-run `customiser.py` afterwards.
+- **reload window**: in addition to the built-in `CmdOrCtrl+R` reload,
+ you can now reload a window with `F5`.
### tray
@@ -141,7 +142,7 @@ as it is a per-table-column style, unlike all others here, it must be prepended
#### hide calculations table row
```css
-[] .notion-table-view-add-row + div {
+.notion-table-view-add-row + div {
display: none !important;
}
```
diff --git a/customiser.py b/customiser.py
index 925472e..2826e2e 100644
--- a/customiser.py
+++ b/customiser.py
@@ -14,12 +14,12 @@ from time import sleep
# for toggling notion visibility
-hotkey = 'ctrl+shift+a'
+hotkey = 'CmdOrCtrl+Shift+A'
# f'{bold}=== title ==={normal}' = headers
# '*' = information
# '...' = actions
-# '##' = warnings
+# '##' = warnings
# '>' = exit
bold = '\033[1m'
diff --git a/docs/changelog.html b/docs/changelog.html
index 58cca37..d59983e 100644
--- a/docs/changelog.html
+++ b/docs/changelog.html
@@ -13,7 +13,8 @@ but can still easily be enabled by following instructions in the v0.5.0 (wip)
-- new: running from the WSL.
+- new: running from the wsl.
+- new: reload window with f5.
- improved: code has been refactored and cleaned up,
inc. file renaming.
- bugfix: un-break having multiple notion windows open.
diff --git a/docs/index.html b/docs/index.html
index 77019be..c4cc928 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -78,9 +78,13 @@ ones that actually look as if they're part of notion.
- by default, ctrl+shift+a
(will hide/show all notion windows to/from the tray).
-to set your own, open customiser.py
and change line 16 (hotkey = 'ctrl+shift+a'
)
-to your preference. you will need to run or re-run customiser.py
afterwards.
+
+- toggle all notion windows to/from the tray:
CmdOrCtrl+Shift+A
by default.
+to set your own, open customiser.py
and change line 16 (hotkey = 'ctrl+shift+a'
)
+to your preference. you will need to run or re-run customiser.py
afterwards.
+- reload window: in addition to the built-in
CmdOrCtrl+R
reload,
+you can now reload a window with F5
.
+
@@ -169,7 +173,7 @@ as it is a per-table-column style, unlike all others here, it must be prepended
- [] .notion-table-view-add-row + div {
+ .notion-table-view-add-row + div {
display: none !important;
}
diff --git a/resources/preload.js b/resources/preload.js
index abaf5da..52b58aa 100644
--- a/resources/preload.js
+++ b/resources/preload.js
@@ -22,12 +22,13 @@ require('electron').remote.getGlobal('setTimeout')(() => {
style.innerHTML = css;
head.appendChild(style);
- /* window control buttons */
- const intervalID = setInterval(insertbuttons, 100);
- function insertbuttons() {
+ const intervalID = setInterval(injection, 100);
+ function injection() {
if (document.querySelector('div.notion-topbar > div') == undefined) return;
const appwindow = require('electron').remote.getCurrentWindow();
+
+ /* window control buttons */
let node = document.querySelector('div.notion-topbar > div'),
element = document.createElement('div');
element.id = 'window-buttons-area';
@@ -82,5 +83,12 @@ require('electron').remote.getGlobal('setTimeout')(() => {
node.appendChild(element);
clearInterval(intervalID);
+
+ /* reload window */
+ document.defaultView.addEventListener(
+ 'keyup',
+ ev => void (ev.code === 'F5' ? appwindow.reload() : 0),
+ true
+ );
}
}, 100);