diff --git a/mods/core/css/shared.css b/mods/core/css/shared.css index 2d0ab61..5a146cc 100644 --- a/mods/core/css/shared.css +++ b/mods/core/css/shared.css @@ -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 { diff --git a/mods/core/menu.js b/mods/core/menu.js index 831d44c..7c4ab78 100644 --- a/mods/core/menu.js +++ b/mods/core/menu.js @@ -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 () => { // ![image_title](source) .replace( /([^\\])?\!\[([^\]]*[^\\\]]?)\]\(([^)]*[^\\)])\)/g, - `$1$2` + `$1$2` ) // [link](destination) .replace( diff --git a/mods/emoji-sets/mod.js b/mods/emoji-sets/mod.js index 966e916..4b0c11b 100644 --- a/mods/emoji-sets/mod.js +++ b/mods/emoji-sets/mod.js @@ -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') diff --git a/mods/right-to-left/mod.js b/mods/right-to-left/mod.js index 18066ee..c0de109 100644 --- a/mods/right-to-left/mod.js +++ b/mods/right-to-left/mod.js @@ -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'); + } + } }); }, }, diff --git a/mods/weekly-view/mod.js b/mods/weekly-view/mod.js new file mode 100644 index 0000000..b288f54 --- /dev/null +++ b/mods/weekly-view/mod.js @@ -0,0 +1,63 @@ +/* + * weekly view + * (c) 2020 dragonwocky (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, + }); + }); + }, + }, +};