mirror of
https://github.com/notion-enhancer/notion-enhancer.git
synced 2025-04-05 13:19:03 +00:00
weekly view working, app relaunch btn in menu modified alert
This commit is contained in:
parent
583e96ac1a
commit
e787427214
@ -158,6 +158,11 @@ s {
|
||||
background: var(--theme--bg_green);
|
||||
}
|
||||
|
||||
[data-relaunch] {
|
||||
text-decoration: underline dotted;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
/* search */
|
||||
|
||||
#search {
|
||||
|
@ -270,8 +270,14 @@ window['__start'] = async () => {
|
||||
if (modified_notice) return;
|
||||
modified_notice = createAlert(
|
||||
'info',
|
||||
`changes may not fully apply until app restart.`
|
||||
`changes may not fully apply until <span data-relaunch>app relaunch</span>.`
|
||||
);
|
||||
modified_notice.el
|
||||
.querySelector('[data-relaunch]')
|
||||
.addEventListener('click', (event) => {
|
||||
electron.remote.app.relaunch();
|
||||
electron.remote.app.quit();
|
||||
});
|
||||
modified_notice.append();
|
||||
}
|
||||
|
||||
|
@ -11,62 +11,98 @@ module.exports = {
|
||||
id: '4c7acaea-6596-4590-85e5-8ac5a1455e8f',
|
||||
tags: ['extension'],
|
||||
name: 'weekly view',
|
||||
desc: 'view 7-day calendars.',
|
||||
desc: 'calendar views named "weekly" will show only the 7 days of this week.',
|
||||
version: '0.5.0',
|
||||
author: 'adihd',
|
||||
hacks: {
|
||||
'renderer/preload.js'(store, __exports) {
|
||||
document.addEventListener('readystatechange', (event) => {
|
||||
if (document.readyState !== 'complete') return false;
|
||||
let queue = [];
|
||||
const observer = new MutationObserver((list, observer) => {
|
||||
if (!queue.length) requestAnimationFrame(process);
|
||||
queue.push(...list);
|
||||
});
|
||||
observer.observe(document, {
|
||||
childList: true,
|
||||
subtree: true,
|
||||
});
|
||||
function process() {
|
||||
queue = [];
|
||||
|
||||
for (let elem of document.getElementsByClassName(
|
||||
'notion-collection-view-select'
|
||||
)) {
|
||||
// console.log("this is working2");
|
||||
if (elem.innerText === 'weekly') {
|
||||
// console.log("this is working3");
|
||||
var days_list = elem.parentElement.parentElement.parentElement.parentElement.getElementsByClassName(
|
||||
'notion-calendar-view-day'
|
||||
);
|
||||
for (let index = 0; index < days_list.length; index++) {
|
||||
// const element = array[index];
|
||||
if (days_list[index].style.background) {
|
||||
days_list[index].parentElement.parentElement.classList.add(
|
||||
'this_week'
|
||||
);
|
||||
// console.log("yay");
|
||||
}
|
||||
}
|
||||
var weeks = document.getElementsByClassName('this_week')[0]
|
||||
.parentElement.children;
|
||||
// delete al div that not contain a class of "this_week"
|
||||
while (weeks.length > 1) {
|
||||
for (let index = 0; index < weeks.length; index++) {
|
||||
// const element = array[index];
|
||||
|
||||
if (weeks[index].classList.contains('this_week')) {
|
||||
console.log('yes');
|
||||
} else {
|
||||
// console.log(index);
|
||||
weeks[index].remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
const attempt_interval = setInterval(enhance, 500);
|
||||
function enhance() {
|
||||
const notion_elem = document.querySelector('.notion-frame');
|
||||
if (!notion_elem) return;
|
||||
clearInterval(attempt_interval);
|
||||
process([{ target: notion_elem }]);
|
||||
const observer = new MutationObserver(process);
|
||||
observer.observe(notion_elem, {
|
||||
childList: true,
|
||||
subtree: true,
|
||||
});
|
||||
function process(list, observer) {
|
||||
const collection_view = document.querySelector(
|
||||
'.notion-collection-view-select'
|
||||
);
|
||||
if (!collection_view || collection_view.innerText != 'weekly')
|
||||
return;
|
||||
const days = collection_view.parentElement.parentElement.parentElement.parentElement.getElementsByClassName(
|
||||
'notion-calendar-view-day'
|
||||
);
|
||||
for (let day of days)
|
||||
day.parentElement.parentElement.style.height = 0;
|
||||
if (days.length) {
|
||||
const today = [...days].find((day) => day.style.background);
|
||||
if (today)
|
||||
today.parentElement.parentElement.style.height = '124px';
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// document.addEventListener('readystatechange', (event) => {
|
||||
// if (document.readyState !== 'complete') return false;
|
||||
// let queue = [];
|
||||
// const observer = new MutationObserver((list, observer) => {
|
||||
// if (!queue.length) requestAnimationFrame(() => process(queue));
|
||||
// queue.push(...list);
|
||||
// });
|
||||
// observer.observe(document, {
|
||||
// // subtree: true,
|
||||
// });
|
||||
// function process(list) {
|
||||
// queue = [];
|
||||
// if (
|
||||
// list.find((e) => e.target.matches('.notion-collection-view-select'))
|
||||
// )
|
||||
// console.log(list);
|
||||
|
||||
// for (let elem of document.getElementsByClassName(
|
||||
// 'notion-collection-view-select'
|
||||
// )) {
|
||||
// // console.log("this is working2");
|
||||
// if (elem.innerText === 'weekly') {
|
||||
// // console.log("this is working3");
|
||||
// var days_list = elem.parentElement.parentElement.parentElement.parentElement.getElementsByClassName(
|
||||
// 'notion-calendar-view-day'
|
||||
// );
|
||||
// for (let index = 0; index < days_list.length; index++) {
|
||||
// // const element = array[index];
|
||||
// if (days_list[index].style.background) {
|
||||
// days_list[index].parentElement.parentElement.classList.add(
|
||||
// 'this_week'
|
||||
// );
|
||||
// // console.log("yay");
|
||||
// }
|
||||
// }
|
||||
// var weeks = document.getElementsByClassName('this_week')[0]
|
||||
// .parentElement.children;
|
||||
// // delete al div that not contain a class of "this_week"
|
||||
// while (weeks.length > 1) {
|
||||
// for (let index = 0; index < weeks.length; index++) {
|
||||
// // const element = array[index];
|
||||
|
||||
// if (weeks[index].classList.contains('this_week')) {
|
||||
// console.log('yes');
|
||||
// } else {
|
||||
// // console.log(index);
|
||||
// weeks[index].style.display = 'none';
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
},
|
||||
},
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user