mirror of
https://github.com/notion-enhancer/notion-enhancer.git
synced 2025-04-06 21:49:03 +00:00
calendar-scroll + temp disable of broken theming
This commit is contained in:
parent
99c166a1ac
commit
46879fe47a
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* notion-enhancer core: bypass-preview
|
* notion-enhancer: bypass-preview
|
||||||
* (c) 2021 dragonwocky <thedragonring.bod@gmail.com> (https://dragonwocky.me/)
|
* (c) 2021 dragonwocky <thedragonring.bod@gmail.com> (https://dragonwocky.me/)
|
||||||
* (https://notion-enhancer.github.io/) under the MIT license
|
* (https://notion-enhancer.github.io/) under the MIT license
|
||||||
*/
|
*/
|
||||||
|
@ -0,0 +1,21 @@
|
|||||||
|
/*
|
||||||
|
* notion-enhancer: calendar-scroll
|
||||||
|
* (c) 2021 dragonwocky <thedragonring.bod@gmail.com> (https://dragonwocky.me/)
|
||||||
|
* (https://notion-enhancer.github.io/) under the MIT license
|
||||||
|
*/
|
||||||
|
|
||||||
|
#calendar-scroll-to-week {
|
||||||
|
background: var(--theme--button_hover);
|
||||||
|
border: 1px solid transparent;
|
||||||
|
font-size: var(--theme--font_label-size);
|
||||||
|
color: var(--theme--text);
|
||||||
|
height: 24px;
|
||||||
|
border-radius: 3px;
|
||||||
|
line-height: 1.2;
|
||||||
|
padding: 0 0.5em;
|
||||||
|
margin-right: 5px;
|
||||||
|
}
|
||||||
|
#calendar-scroll-to-week:hover {
|
||||||
|
background: transparent;
|
||||||
|
border: 1px solid var(--theme--button_hover);
|
||||||
|
}
|
@ -0,0 +1,64 @@
|
|||||||
|
/*
|
||||||
|
* notion-enhancer core: bypass-preview
|
||||||
|
* (c) 2021 dragonwocky <thedragonring.bod@gmail.com> (https://dragonwocky.me/)
|
||||||
|
* (https://notion-enhancer.github.io/) under the MIT license
|
||||||
|
*/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
import { web } from '../../api.js';
|
||||||
|
|
||||||
|
const $button = web.createElement(
|
||||||
|
web.html`<button id="calendar-scroll-to-week">Scroll</button>`
|
||||||
|
);
|
||||||
|
$button.addEventListener('click', async (event) => {
|
||||||
|
let $day = document.querySelector('.notion-calendar-view-day[style*="background:"]');
|
||||||
|
while (!$day) {
|
||||||
|
const $toolbar = document.querySelector(
|
||||||
|
'.notion-calendar-view > :first-child > :first-child > :first-child'
|
||||||
|
),
|
||||||
|
year = +$toolbar.children[0].innerText.split(' ')[1],
|
||||||
|
month = {
|
||||||
|
'January': 0,
|
||||||
|
'February': 1,
|
||||||
|
'March': 2,
|
||||||
|
'April': 3,
|
||||||
|
'May': 4,
|
||||||
|
'June': 5,
|
||||||
|
'July': 6,
|
||||||
|
'August': 7,
|
||||||
|
'September': 8,
|
||||||
|
'October': 9,
|
||||||
|
'November': 10,
|
||||||
|
'December': 11,
|
||||||
|
}[$toolbar.children[0].innerText.split(' ')[0]],
|
||||||
|
now = new Date();
|
||||||
|
switch (true) {
|
||||||
|
case now.getFullYear() < year:
|
||||||
|
case now.getFullYear() === year && now.getMonth() < month:
|
||||||
|
$toolbar.children[3].click();
|
||||||
|
break;
|
||||||
|
case now.getFullYear() > year:
|
||||||
|
case now.getFullYear() === year && now.getMonth() > month:
|
||||||
|
$toolbar.children[5].click();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
await new Promise((res, rej) => requestAnimationFrame(res));
|
||||||
|
$day = document.querySelector('.notion-calendar-view-day[style*="background:"]');
|
||||||
|
}
|
||||||
|
await new Promise((res, rej) => requestAnimationFrame(res));
|
||||||
|
}
|
||||||
|
const $scroller = document.querySelector('.notion-frame .notion-scroller');
|
||||||
|
$scroller.scroll({
|
||||||
|
top: $day.offsetParent.offsetParent.offsetTop + 70,
|
||||||
|
behavior: 'auto',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
web.addDocumentObserver((event) => {
|
||||||
|
if (document.contains($button)) return;
|
||||||
|
const toolbar = document.querySelector(
|
||||||
|
'.notion-calendar-view > :first-child > :first-child > :first-child'
|
||||||
|
);
|
||||||
|
if (toolbar) toolbar.insertBefore($button, toolbar.children[2]);
|
||||||
|
});
|
@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"name": "calendar-scroll",
|
||||||
|
"id": "b1c7db33-dfee-489a-a76c-0dd66f7ed29a",
|
||||||
|
"description": "add a button to scroll down to the current week in fullpage/infinite-scroll calendars.",
|
||||||
|
"version": "0.2.0",
|
||||||
|
"tags": ["extension", "shortcut"],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "dragonwocky",
|
||||||
|
"email": "thedragonring.bod@gmail.com",
|
||||||
|
"url": "https://dragonwocky.me/",
|
||||||
|
"icon": "https://dragonwocky.me/avatar.jpg"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"js": {
|
||||||
|
"client": ["client.js"]
|
||||||
|
},
|
||||||
|
"css": {
|
||||||
|
"client": ["client.css"]
|
||||||
|
}
|
||||||
|
}
|
@ -56,12 +56,14 @@ function navigator(event) {
|
|||||||
export async function load(force = false) {
|
export async function load(force = false) {
|
||||||
const $container = document.querySelector('main'),
|
const $container = document.querySelector('main'),
|
||||||
search = getSearch(),
|
search = getSearch(),
|
||||||
fallbackView = () =>
|
fallbackView = () => {
|
||||||
window.history.replaceState(
|
window.history.replaceState(
|
||||||
{ search: `?view=${defaultView}`, hash: '' },
|
{ search: `?view=${defaultView}`, hash: '' },
|
||||||
null,
|
null,
|
||||||
`?view=${defaultView}`
|
`?view=${defaultView}`
|
||||||
);
|
);
|
||||||
|
return load();
|
||||||
|
};
|
||||||
if (force || !search.get('view') || document.body.dataset.view !== search.get('view')) {
|
if (force || !search.get('view') || document.body.dataset.view !== search.get('view')) {
|
||||||
if (views.get(search.get('view'))) {
|
if (views.get(search.get('view'))) {
|
||||||
const $body = await (views.get(search.get('view')) || (() => void 0))();
|
const $body = await (views.get(search.get('view')) || (() => void 0))();
|
||||||
|
@ -2,5 +2,6 @@
|
|||||||
"menu@a6621988-551d-495a-97d8-3c568bca2e9e",
|
"menu@a6621988-551d-495a-97d8-3c568bca2e9e",
|
||||||
"theming@0f0bf8b6-eae6-4273-b307-8fc43f2ee082",
|
"theming@0f0bf8b6-eae6-4273-b307-8fc43f2ee082",
|
||||||
"tweaks@5174a483-c88d-4bf8-a95f-35cd330b76e2",
|
"tweaks@5174a483-c88d-4bf8-a95f-35cd330b76e2",
|
||||||
"bypass-preview@cb6fd684-f113-4a7a-9423-8f0f0cff069f"
|
"bypass-preview@cb6fd684-f113-4a7a-9423-8f0f0cff069f",
|
||||||
|
"calendar-scroll@b1c7db33-dfee-489a-a76c-0dd66f7ed29a"
|
||||||
]
|
]
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
],
|
],
|
||||||
"css": {
|
"css": {
|
||||||
"frame": ["variables.css"],
|
"frame": ["variables.css"],
|
||||||
"client": ["variables.css", "client.css", "prism.css"],
|
"client": ["variables.css", "prism.css"],
|
||||||
"menu": ["variables.css", "prism.css"]
|
"menu": ["variables.css", "prism.css"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user