mirror of
https://github.com/notion-enhancer/notion-enhancer.git
synced 2025-04-08 06:29:03 +00:00
Merge pull request #125 from amv146/bypass-preview-fix
Fixed bypass preview
This commit is contained in:
commit
57b47b82aa
@ -4,28 +4,34 @@
|
|||||||
* (https://notion-enhancer.github.io/) under the MIT license
|
* (https://notion-enhancer.github.io/) under the MIT license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
'use strict';
|
"use strict";
|
||||||
|
|
||||||
export default function ({ web, notion }, db) {
|
export default function ({ web, notion }, db) {
|
||||||
let _openPage = {};
|
let _openPage = {};
|
||||||
|
|
||||||
const getCurrentPage = () => ({
|
const getCurrentPage = () => ({
|
||||||
type: web.queryParams().get('p') ? 'preview' : 'page',
|
type: web.queryParams().get("p") ? "preview" : "page",
|
||||||
id: notion.getPageID(),
|
id: notion.getPageID(),
|
||||||
});
|
});
|
||||||
|
|
||||||
const interceptPreview = () => {
|
const interceptPreview = () => {
|
||||||
const currentPage = getCurrentPage();
|
const currentPage = getCurrentPage();
|
||||||
if (currentPage.id !== _openPage.id || currentPage.type !== _openPage.type) {
|
if (
|
||||||
|
currentPage.id !== _openPage.id ||
|
||||||
|
currentPage.type !== _openPage.type
|
||||||
|
) {
|
||||||
const $openAsPage = document.querySelector(
|
const $openAsPage = document.querySelector(
|
||||||
'.notion-peek-renderer [style*="height: 45px;"] a'
|
".notion-peek-renderer a > div"
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($openAsPage) {
|
if ($openAsPage) {
|
||||||
if (currentPage.id === _openPage.id && currentPage.type === 'preview') {
|
if (currentPage.id === _openPage.id && currentPage.type === "preview") {
|
||||||
history.back();
|
history.back();
|
||||||
} else $openAsPage.click();
|
} else $openAsPage.click();
|
||||||
}
|
}
|
||||||
|
|
||||||
_openPage = getCurrentPage();
|
_openPage = getCurrentPage();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
web.addDocumentObserver(interceptPreview, ['.notion-peek-renderer']);
|
web.addDocumentObserver(interceptPreview, [".notion-peek-renderer"]);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user