mirror of
https://github.com/notion-enhancer/notion-enhancer.git
synced 2025-04-05 05:09:03 +00:00
perf improvements + fullwidth page banner in preview
This commit is contained in:
parent
a57b7ca57a
commit
7b12815953
@ -97,7 +97,6 @@
|
||||
max-width: var(--theme--preview-width) !important;
|
||||
}
|
||||
|
||||
.notion-peek-renderer .notion-scroller.vertical > div:nth-child(1) > div,
|
||||
.notion-peek-renderer .notion-scroller.vertical > div:nth-child(2),
|
||||
.notion-peek-renderer .notion-page-view-discussion,
|
||||
.notion-peek-renderer .notion-page-content {
|
||||
|
@ -63,7 +63,7 @@ window['__start'] = async () => {
|
||||
return {
|
||||
el,
|
||||
resolve() {
|
||||
el.outerHTML = '';
|
||||
el.remove();
|
||||
},
|
||||
prepend() {
|
||||
document.querySelector('#alerts').prepend(el);
|
||||
@ -250,7 +250,7 @@ window['__start'] = async () => {
|
||||
// 
|
||||
.replace(
|
||||
/([^\\])?\!\[([^\]]*[^\\\]]?)\]\(([^)]*[^\\)])\)/g,
|
||||
`$1<img alt="$2" src="$3" onerror="this.outerHTML=''">`
|
||||
`$1<img alt="$2" src="$3" onerror="this.remove()">`
|
||||
)
|
||||
// [link](destination)
|
||||
.replace(
|
||||
|
@ -47,7 +47,7 @@ module.exports = {
|
||||
.querySelectorAll(
|
||||
'[src*="notion-emojis.s3-us-west-2.amazonaws.com"]:not(.notion-emoji)'
|
||||
)
|
||||
.forEach((el) => (el.outerHTML = ''));
|
||||
.forEach((el) => el.remove());
|
||||
if (
|
||||
(store().style === 'microsoft' && process.platform === 'win32') ||
|
||||
(store().style === 'apple' && process.platform === 'darwin')
|
||||
|
@ -18,22 +18,31 @@ module.exports = {
|
||||
'renderer/preload.js'(store, __exports) {
|
||||
document.addEventListener('readystatechange', (event) => {
|
||||
if (document.readyState !== 'complete') return false;
|
||||
let queue = [];
|
||||
const observer = new MutationObserver((list, observer) => {
|
||||
document
|
||||
.querySelectorAll(
|
||||
'.notion-page-content > div[data-block-id]:not([dir])'
|
||||
)
|
||||
.forEach((block) => block.setAttribute('dir', 'auto'));
|
||||
document
|
||||
.querySelectorAll("div[placeholder='List']")
|
||||
.forEach((item) => {
|
||||
item.style['text-align'] = 'start';
|
||||
});
|
||||
if (!queue.length) requestAnimationFrame(process);
|
||||
queue.push(...list);
|
||||
console.log(queue.length);
|
||||
});
|
||||
observer.observe(document, {
|
||||
childList: true,
|
||||
subtree: true,
|
||||
characterData: true,
|
||||
});
|
||||
function process() {
|
||||
const cache = queue;
|
||||
queue = [];
|
||||
for (let { target } of cache) {
|
||||
if (!target.innerText) return;
|
||||
if (target.getAttribute('dir') !== 'auto')
|
||||
target.setAttribute('dir', 'auto');
|
||||
if (
|
||||
getComputedStyle(target).getPropertyValue('text-align') !==
|
||||
'start'
|
||||
)
|
||||
target.style.setProperty('text-align', 'start');
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
},
|
||||
|
63
mods/weekly-view/mod.js
Normal file
63
mods/weekly-view/mod.js
Normal file
@ -0,0 +1,63 @@
|
||||
/*
|
||||
* weekly view
|
||||
* (c) 2020 dragonwocky <thedragonring.bod@gmail.com> (https://dragonwocky.me/)
|
||||
* (c) 2020 adihd
|
||||
* under the MIT license
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
id: '4c7acaea-6596-4590-85e5-8ac5a1455e8f',
|
||||
tags: ['extension'],
|
||||
name: 'weekly view',
|
||||
desc: 'view 7-day calendars.',
|
||||
version: '0.5.0',
|
||||
author: 'adihd',
|
||||
hacks: {
|
||||
'renderer/preload.js'(store, __exports) {
|
||||
document.addEventListener('readystatechange', (event) => {
|
||||
if (document.readyState !== 'complete') return false;
|
||||
const observer = new MutationObserver((list, observer) => {
|
||||
document
|
||||
.querySelectorAll('.notion-collection-view-select > :nth-child(2)')
|
||||
.forEach((collection_view) => {
|
||||
if (collection_view.innerText === 'weekly') {
|
||||
collection_view =
|
||||
collection_view.parentElement.parentElement.parentElement
|
||||
.parentElement.parentElement;
|
||||
// collection_view.classList.add('weekly_view');
|
||||
// document
|
||||
// .querySelectorAll('.adi_week_cal .notion-calendar-view-day')
|
||||
// .forEach((day) => {
|
||||
// if (day.style.background)
|
||||
// day.parentElement.parentElement.classList.add(
|
||||
// 'this_week'
|
||||
// );
|
||||
// });
|
||||
// var weeks = document.querySelectorAll('.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();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
});
|
||||
});
|
||||
observer.observe(document, {
|
||||
childList: true,
|
||||
subtree: true,
|
||||
attributes: true,
|
||||
});
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
Loading…
Reference in New Issue
Block a user