mirror of
https://github.com/notion-enhancer/notion-enhancer.git
synced 2025-04-08 06:29:03 +00:00
#114 back/forward arrows work with bypass preview
This commit is contained in:
parent
a31a93e206
commit
21b3802e08
@ -11,6 +11,8 @@
|
||||
|
||||
- bugfix: font chooser will continue iterating through fonts after encountering a blank option.
|
||||
- bugfix: block indents are no longer overriden.
|
||||
- bugfix: neutral does not force full width pages.
|
||||
- bugfix: bypass preview extension works with the back/forward arrows.
|
||||
|
||||
### v0.9.0 (2020-09-20)
|
||||
|
||||
|
@ -30,6 +30,7 @@ download:
|
||||
```sh
|
||||
git clone https://github.com/dragonwocky/notion-enhancer
|
||||
cd notion-enhancer
|
||||
git checkout dev
|
||||
npm link
|
||||
```
|
||||
|
||||
@ -52,6 +53,12 @@ to keep a consistent informative code style it is preferred to name variables wi
|
||||
`snake_case`, functions/methods with `camelCase`, and classes with `PascalCase`.
|
||||
if a variable is a reference to a DOM element, it may be helpful to prefix it with a `$`.
|
||||
|
||||
some variables beginning with a double underscore are `__folder` paths and `ALL_CAPS` variables
|
||||
are constant. this is not required, but these styles should not be used for any other purpose.
|
||||
|
||||
the master branch is kept consistent with the current release,
|
||||
so all changes should be made to the dev branch.
|
||||
|
||||
## review
|
||||
|
||||
active core devs will manually look through each pull request and communicate with contributors before merging to
|
||||
|
@ -19,23 +19,48 @@ module.exports = {
|
||||
if (document.readyState !== 'complete') return false;
|
||||
const attempt_interval = setInterval(enhance, 500);
|
||||
function enhance() {
|
||||
const notion_elem = document.querySelector(
|
||||
'.notion-default-overlay-container'
|
||||
);
|
||||
const notion_elem = document.querySelector('.notion-app-inner');
|
||||
if (!notion_elem) return;
|
||||
clearInterval(attempt_interval);
|
||||
|
||||
process();
|
||||
const observer = new MutationObserver(process);
|
||||
observer.observe(notion_elem, {
|
||||
childList: true,
|
||||
subtree: true,
|
||||
});
|
||||
|
||||
let pageHistory = [];
|
||||
process();
|
||||
function process(list, observer) {
|
||||
let preview = document.querySelector(
|
||||
const pageID = (location.search
|
||||
.slice(1)
|
||||
.split('&')
|
||||
.map((opt) => opt.split('='))
|
||||
.find((opt) => opt[0] === 'p') || [
|
||||
'',
|
||||
...location.pathname.split(/(-|\/)/g).reverse(),
|
||||
])[1],
|
||||
preview = document.querySelector(
|
||||
'.notion-peek-renderer [style*="height: 45px;"] a'
|
||||
);
|
||||
if (preview) preview.click();
|
||||
if (
|
||||
pageID &&
|
||||
(!pageHistory[0] ||
|
||||
pageHistory[0][0] !== pageID ||
|
||||
pageHistory[0][1] !== !!preview)
|
||||
) {
|
||||
if (preview) {
|
||||
if (
|
||||
pageHistory[1] &&
|
||||
pageHistory[0][0] === pageID &&
|
||||
pageHistory[1][0] === pageID &&
|
||||
pageHistory[1][1]
|
||||
) {
|
||||
document.querySelector('.notion-history-back-button').click();
|
||||
} else preview.click();
|
||||
}
|
||||
// most recent is at start for easier access
|
||||
pageHistory.unshift([pageID, !!preview]);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
9
mods/bypass-preview/styles.css
Normal file
9
mods/bypass-preview/styles.css
Normal file
@ -0,0 +1,9 @@
|
||||
/*
|
||||
* bypass preview
|
||||
* (c) 2020 dragonwocky <thedragonring.bod@gmail.com> (https://dragonwocky.me/)
|
||||
* under the MIT license
|
||||
*/
|
||||
|
||||
.notion-peek-renderer {
|
||||
opacity: 0;
|
||||
}
|
@ -119,6 +119,7 @@ module.exports = {
|
||||
''
|
||||
)}`;
|
||||
$page.previousElementSibling.children[0].appendChild($container);
|
||||
if (!$container.offsetParent) return;
|
||||
$container.offsetParent.appendChild($tooltip);
|
||||
$container
|
||||
.querySelectorAll('p')
|
||||
@ -130,7 +131,6 @@ module.exports = {
|
||||
$container.querySelectorAll('[data-tooltip]').forEach((el) => {
|
||||
el.addEventListener('mouseenter', (e) => {
|
||||
$tooltip.innerText = el.getAttribute('data-tooltip');
|
||||
console.log(e.target);
|
||||
$tooltip.style.top = el.parentElement.offsetTop + 2.5 + 'px';
|
||||
$tooltip.style.left =
|
||||
el.parentElement.offsetLeft +
|
||||
|
Loading…
Reference in New Issue
Block a user