mirror of
https://github.com/notion-enhancer/notion-enhancer.git
synced 2025-04-06 05:29:02 +00:00
#114 back/forward arrows work with bypass preview
This commit is contained in:
parent
5655043b36
commit
287e3551b5
@ -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(
|
||||
'.notion-peek-renderer [style*="height: 45px;"] a'
|
||||
);
|
||||
if (preview) preview.click();
|
||||
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 (
|
||||
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
repo/bypass-preview/styles.css
Normal file
9
repo/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