diff --git a/extension/api/_.mjs b/extension/api/_.mjs
index 9f48011..bd0e39d 100644
--- a/extension/api/_.mjs
+++ b/extension/api/_.mjs
@@ -10,14 +10,15 @@
/** environment-specific methods and constants */
export * as env from './env.mjs';
+/** environment-specific data persistence */
+export * as storage from './storage.mjs';
+
/** helpers for formatting or parsing text */
export * as fmt from './fmt.mjs';
/** environment-specific filesystem reading */
export * as fs from './fs.mjs';
/** interactions with the enhancer's repository of mods */
export * as registry from './registry.mjs';
-/** environment-specific data persistence */
-export * as storage from './storage.mjs';
/** pattern and type validators */
export * as validation from './validation.mjs';
/** helpers for manipulation of a webpage */
diff --git a/extension/api/env.mjs b/extension/api/env.mjs
index 43297fc..db7be08 100644
--- a/extension/api/env.mjs
+++ b/extension/api/env.mjs
@@ -30,8 +30,7 @@ export const supported = ['linux', 'win32', 'darwin', 'extension'];
export const version = chrome.runtime.getManifest().version;
/** open the enhancer's menu */
-export const openEnhancerMenu = () =>
- chrome.runtime.sendMessage({ action: 'openEnhancerMenu' });
+export const focusMenu = () => chrome.runtime.sendMessage({ action: 'focusMenu' });
/** focus an active notion tab */
export const focusNotion = () => chrome.runtime.sendMessage({ action: 'focusNotion' });
diff --git a/extension/api/fmt.mjs b/extension/api/fmt.mjs
index 743cc6b..10d5092 100644
--- a/extension/api/fmt.mjs
+++ b/extension/api/fmt.mjs
@@ -11,6 +11,8 @@
* @module notion-enhancer/api/fmt
*/
+import * as web from './web.mjs';
+
import '../dep/prism.min.js';
/** syntax highlighting using https://prismjs.com/ */
export const prism = Prism;
@@ -19,7 +21,7 @@ Prism.hooks.add('complete', async (event) => {
event.element.parentElement.removeAttribute('tabindex');
event.element.parentElement.parentElement
.querySelector('.copy-to-clipboard-button')
- .prepend(web.createElement(await web.getIcon('fa/regular/copy')));
+ .prepend(web.html`${await web.icon('clipboard')}`);
});
import '../dep/markdown-it.min.js';
@@ -27,7 +29,7 @@ import '../dep/markdown-it.min.js';
export const md = new markdownit({
linkify: true,
highlight: (str, lang) =>
- web.html`
${web.escapeHtml(
+ web.html`${web.escape(
str
)}
`,
});
@@ -36,7 +38,7 @@ md.renderer.rules.code_block = (tokens, idx, options, env, slf) => {
if (attrIdx === -1) {
tokens[idx].attrPush(['class', 'match-braces language-plaintext']);
} else tokens[idx].attrs[attrIdx][1] = 'match-braces language-plaintext';
- return web.html`${web.escapeHtml(
+ return web.html`${web.escape(
tokens[idx].content
)}
\n`;
};
@@ -47,7 +49,7 @@ md.core.ruler.push(
state.tokens.forEach(function (token, i) {
if (token.type === 'heading_open') {
const text = md.renderer.render(state.tokens[i + 1].children, md.options),
- slug = fmt.slugger(text, slugs);
+ slug = slugger(text, slugs);
slugs.add(slug);
const attrIdx = token.attrIndex('id');
if (attrIdx === -1) {
diff --git a/extension/api/registry.mjs b/extension/api/registry.mjs
index 2a6215a..910d4ae 100644
--- a/extension/api/registry.mjs
+++ b/extension/api/registry.mjs
@@ -242,8 +242,7 @@ export const list = async (filter = (mod) => true) => {
const mod = await getJSON(`repo/${dir}/mod.json`);
mod._dir = dir;
if (await validate(mod)) _cache.push(mod);
- } catch (e) {
- console.log(e);
+ } catch {
_errors.push({ source: dir, message: 'invalid mod.json' });
}
}
diff --git a/extension/api/web.mjs b/extension/api/web.mjs
index dd476f7..c4ab25c 100644
--- a/extension/api/web.mjs
+++ b/extension/api/web.mjs
@@ -18,7 +18,7 @@ const _hotkeyEventListeners = [],
_documentObserverListeners = [],
_documentObserverEvents = [];
-let _$featherStylesheet, _$tooltip, _$tooltipStylesheet, _hotkeyEvent, _documentObserver;
+let _$tooltip, _$tooltipStylesheet, _hotkeyEvent, _documentObserver;
import '../dep/jscolor.min.js';
/** color picker with alpha channel using https://jscolor.com/ */
@@ -152,22 +152,13 @@ export const loadStylesheet = (path) => {
* @returns {string} an svg string
*/
export const icon = (name, attrs = {}) => {
- if (!_$featherStylesheet) {
- _$featherStylesheet = html``;
- render(document.head, _$featherStylesheet);
- }
- attrs.class = ((attrs.class || '') + ' enhancer--feather').trim();
- return ``;
+ attrs.style = (
+ (attrs.style || '') +
+ ';stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;fill:none;'
+ ).trim();
+ return ``;
};
/**
@@ -177,9 +168,9 @@ export const icon = (name, attrs = {}) => {
*/
export const tooltip = ($ref, text) => {
if (!_$tooltip) {
- _$tooltip = html``;
- _$tooltipStylesheet = html``;
diff --git a/extension/launcher.js b/extension/launcher.js
index b307801..698e5ce 100644
--- a/extension/launcher.js
+++ b/extension/launcher.js
@@ -6,11 +6,12 @@
'use strict';
-// only load if user is logged into notion and viewing a page
-if (
- localStorage['LRU:KeyValueStore2:current-user-id'] &&
- location.pathname.split(/[/-]/g).reverse()[0].length === 32
-) {
+const site = location.host.endsWith('.notion.site'),
+ loggedIn = localStorage['LRU:KeyValueStore2:current-user-id'],
+ page = location.pathname.split(/[/-]/g).reverse()[0].length === 32,
+ home = location.pathname === '/';
+
+if (site || (loggedIn && (page || home))) {
import(chrome.runtime.getURL('api/_.mjs')).then(async (api) => {
const { registry, web } = api;
for (const mod of await registry.list((mod) => registry.enabled(mod.id))) {
diff --git a/extension/manifest.json b/extension/manifest.json
index 9b3101a..b57f399 100644
--- a/extension/manifest.json
+++ b/extension/manifest.json
@@ -19,15 +19,15 @@
"web_accessible_resources": [
{
"resources": ["api/*", "dep/*", "icon/*", "repo/*"],
- "matches": ["https://*.notion.so/*"]
+ "matches": ["https://*.notion.so/*", "https://*.notion.site/*"]
}
],
"content_scripts": [
{
- "matches": ["https://*.notion.so/*"],
+ "matches": ["https://*.notion.so/*", "https://*.notion.site/*"],
"js": ["launcher.js"]
}
],
"permissions": ["tabs", "storage", "unlimitedStorage"],
- "host_permissions": ["https://*.notion.so/*", ""]
+ "host_permissions": ["https://*.notion.so/*", "https://*.notion.site/*", ""]
}
diff --git a/extension/repo/calendar-scroll@b1c7db33-dfee-489a-a76c-0dd66f7ed29a/mod.json b/extension/repo/calendar-scroll@b1c7db33-dfee-489a-a76c-0dd66f7ed29a/mod.json
index 8590126..1e38790 100644
--- a/extension/repo/calendar-scroll@b1c7db33-dfee-489a-a76c-0dd66f7ed29a/mod.json
+++ b/extension/repo/calendar-scroll@b1c7db33-dfee-489a-a76c-0dd66f7ed29a/mod.json
@@ -2,7 +2,7 @@
"name": "calendar-scroll",
"id": "b1c7db33-dfee-489a-a76c-0dd66f7ed29a",
"version": "0.2.0",
- "description": "add a button to scroll down to the current week in fullpage/infinite-scroll calendars.",
+ "description": "add a button to jump down to the current week in fullpage/infinite-scroll calendars.",
"tags": ["extension", "shortcut"],
"authors": [
{
diff --git a/extension/repo/menu@a6621988-551d-495a-97d8-3c568bca2e9e/client.mjs b/extension/repo/menu@a6621988-551d-495a-97d8-3c568bca2e9e/client.mjs
index faf50f7..d7b15db 100644
--- a/extension/repo/menu@a6621988-551d-495a-97d8-3c568bca2e9e/client.mjs
+++ b/extension/repo/menu@a6621988-551d-495a-97d8-3c568bca2e9e/client.mjs
@@ -7,8 +7,18 @@
'use strict';
export default async function (api, db) {
- const { env, fs, registry, web } = api,
- sidebarSelector = '.notion-sidebar-container .notion-sidebar > div:nth-child(4)';
+ const { env, fs, registry, web } = api;
+
+ web.addHotkeyListener(await db.get(['hotkey']), env.focusMenu);
+
+ const updateTheme = () =>
+ db.set(['theme'], document.querySelector('.notion-dark-theme') ? 'dark' : 'light');
+ web.addDocumentObserver((mutation) => {
+ if (mutation.target === document.body) updateTheme();
+ });
+ updateTheme();
+
+ const sidebarSelector = '.notion-sidebar-container .notion-sidebar > div:nth-child(4)';
await web.whenReady([sidebarSelector]);
const $sidebarLink = web.html`
`;
- $sidebarLink.addEventListener('click', env.openEnhancerMenu);
- web.addHotkeyListener(await db.get(['hotkey']), env.openEnhancerMenu);
-
- const updateTheme = () =>
- db.set(['theme'], document.querySelector('.notion-dark-theme') ? 'dark' : 'light');
- web.addDocumentObserver((mutation) => {
- if (mutation.target === document.body) updateTheme();
- });
- updateTheme();
+ $sidebarLink.addEventListener('click', env.focusMenu);
const notifications = {
cache: await db.get(['notifications'], []),
diff --git a/extension/repo/menu@a6621988-551d-495a-97d8-3c568bca2e9e/markdown.css b/extension/repo/menu@a6621988-551d-495a-97d8-3c568bca2e9e/markdown.css
index 2391359..b2247b7 100644
--- a/extension/repo/menu@a6621988-551d-495a-97d8-3c568bca2e9e/markdown.css
+++ b/extension/repo/menu@a6621988-551d-495a-97d8-3c568bca2e9e/markdown.css
@@ -4,64 +4,65 @@
* (https://notion-enhancer.github.io/) under the MIT license
*/
-.enhancer--markdown table {
+.markdown table {
border-spacing: 0;
border: 1px solid var(--theme--ui_divider);
}
-.enhancer--markdown table th {
+.markdown table th {
text-align: left;
}
-.enhancer--markdown table th,
-.enhancer--markdown table td {
+.markdown table th,
+.markdown table td {
padding: 5px 8px 6px;
border: 1px solid var(--theme--ui_divider);
}
-.enhancer--markdown h1 {
+.markdown h1 {
font-size: 1.875rem;
margin: 1rem 0 0.5rem 0;
}
-.enhancer--markdown h2 {
+.markdown h2 {
font-size: 1.5rem;
margin: 1rem 0 0.5rem 0;
}
-.enhancer--markdown h3 {
+.markdown h3 {
font-size: 1.25rem;
margin: 1rem 0 0.5rem 0;
}
-.enhancer--markdown ul,
-.enhancer--markdown ol {
+.markdown ul,
+.markdown ol {
padding-left: 1.25rem;
}
-.enhancer--markdown li {
+.markdown li {
margin: 0.4rem 0;
}
-.enhancer--markdown ol li {
+.markdown ol li {
padding-left: 0.25rem;
}
-.enhancer--markdown blockquote {
+.markdown blockquote {
border-left: 2px solid currentColor;
padding-left: 0.75rem;
margin: 0.5rem 0;
}
-.enhancer--markdown hr {
+.markdown hr {
border: 0.5px solid var(--theme--ui_divider);
}
-.enhancer--markdown a {
+.markdown.markdown-inline a {
opacity: 0.7;
text-decoration: none;
border-bottom: 0.05em solid var(--theme--text_ui);
}
-.enhancer--markdown a:hover {
+.markdown.markdown-inline a:hover {
opacity: 0.9;
}
-.enhancer--markdown :not(pre) > code {
+.markdown :not(pre) > code,
+.markdown-inline code {
padding: 0.2em 0.4em;
border-radius: 3px;
background: var(--theme--code_inline);
color: var(--theme--code_inline-text);
}
-.enhancer--markdown pre {
+.markdown pre {
padding: 2em 1.25em;
border-radius: 3px;
tab-size: 2;
@@ -70,8 +71,8 @@
background: var(--theme--code);
color: var(--theme--code_plain);
}
-.enhancer--markdown pre,
-.enhancer--markdown code {
+.markdown pre,
+.markdown.markdown-inline code {
font-family: var(--theme--font_code);
font-size: 0.796875rem;
text-align: left;
@@ -85,7 +86,7 @@
/*
* https://prismjs.com/plugins/inline-color/
*/
-.enhancer--markdown .inline-color-wrapper {
+.markdown .inline-color-wrapper {
/*
* base64 svg (https://stackoverflow.com/a/21626701/7595472 - prevents visual glitches)
*