mirror of
https://github.com/notion-enhancer/notion-enhancer.git
synced 2025-04-06 21:49:03 +00:00
downgrade to manifest v2 for firefox support (tested/working)
This commit is contained in:
parent
ccbcdaf76a
commit
95621cd029
@ -15,13 +15,13 @@
|
||||
* the environment/platform name code is currently being executed in
|
||||
* @constant {string}
|
||||
*/
|
||||
export const name = 'chrome';
|
||||
export const name = 'extension';
|
||||
|
||||
/**
|
||||
* all environments/platforms currently supported by the enhancer
|
||||
* @constant {array<string>}
|
||||
*/
|
||||
export const supported = ['linux', 'win32', 'darwin', 'chrome', 'firefox'];
|
||||
export const supported = ['linux', 'win32', 'darwin', 'extension'];
|
||||
|
||||
/**
|
||||
* the current version of the enhancer
|
||||
|
@ -6,27 +6,29 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
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 === '/';
|
||||
(async () => {
|
||||
if (location.pathname === '/') await new Promise((res, rej) => setTimeout(res, 500));
|
||||
|
||||
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))) {
|
||||
for (const sheet of mod.css?.client || []) {
|
||||
web.loadStylesheet(`repo/${mod._dir}/${sheet}`);
|
||||
const site = location.host.endsWith('.notion.site'),
|
||||
page = location.pathname.split(/[/-]/g).reverse()[0].length === 32;
|
||||
|
||||
if (site || page) {
|
||||
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))) {
|
||||
for (const sheet of mod.css?.client || []) {
|
||||
web.loadStylesheet(`repo/${mod._dir}/${sheet}`);
|
||||
}
|
||||
for (let script of mod.js?.client || []) {
|
||||
script = await import(chrome.runtime.getURL(`repo/${mod._dir}/${script}`));
|
||||
script.default(api, await registry.db(mod.id));
|
||||
}
|
||||
}
|
||||
for (let script of mod.js?.client || []) {
|
||||
script = await import(chrome.runtime.getURL(`repo/${mod._dir}/${script}`));
|
||||
script.default(api, await registry.db(mod.id));
|
||||
const errors = await registry.errors();
|
||||
if (errors.length) {
|
||||
console.log('[notion-enhancer] registry errors:');
|
||||
console.table(errors);
|
||||
}
|
||||
}
|
||||
const errors = await registry.errors();
|
||||
if (errors.length) {
|
||||
console.log('[notion-enhancer] registry errors:');
|
||||
console.table(errors);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
})();
|
||||
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"manifest_version": 3,
|
||||
"manifest_version": 2,
|
||||
"name": "notion-enhancer",
|
||||
"version": "0.11.0",
|
||||
"author": "dragonwocky <thedragonring.bod@gmail.com> (https://dragonwocky.me/)",
|
||||
@ -13,21 +13,25 @@
|
||||
"256": "icon/colour-x256.png",
|
||||
"512": "icon/colour-x512.png"
|
||||
},
|
||||
"action": {},
|
||||
"background": { "service_worker": "worker.js" },
|
||||
"options_page": "repo/menu@a6621988-551d-495a-97d8-3c568bca2e9e/menu.html",
|
||||
"web_accessible_resources": [
|
||||
{
|
||||
"resources": ["api/*", "dep/*", "icon/*", "repo/*"],
|
||||
"matches": ["https://*.notion.so/*", "https://*.notion.site/*"]
|
||||
}
|
||||
],
|
||||
"browser_action": {},
|
||||
"background": { "scripts": ["worker.js"] },
|
||||
"options_ui": {
|
||||
"page": "repo/menu@a6621988-551d-495a-97d8-3c568bca2e9e/menu.html",
|
||||
"open_in_tab": true
|
||||
},
|
||||
"web_accessible_resources": ["api/*", "dep/*", "icon/*", "repo/*"],
|
||||
"content_scripts": [
|
||||
{
|
||||
"matches": ["https://*.notion.so/*", "https://*.notion.site/*"],
|
||||
"js": ["launcher.js"]
|
||||
}
|
||||
],
|
||||
"permissions": ["tabs", "storage", "unlimitedStorage"],
|
||||
"host_permissions": ["https://*.notion.so/*", "https://*.notion.site/*", "<all_urls>"]
|
||||
"permissions": [
|
||||
"tabs",
|
||||
"storage",
|
||||
"unlimitedStorage",
|
||||
"https://*.notion.so/*",
|
||||
"https://*.notion.site/*",
|
||||
"<all_urls>"
|
||||
]
|
||||
}
|
||||
|
@ -20,7 +20,9 @@ export function removeView(name) {
|
||||
|
||||
function router(event) {
|
||||
event.preventDefault();
|
||||
const anchor = event.path.find((anchor) => anchor.nodeName === 'A');
|
||||
const anchor = event.path
|
||||
? event.path.find((anchor) => anchor.nodeName === 'A')
|
||||
: event.target;
|
||||
if (location.search !== anchor.getAttribute('href')) {
|
||||
window.history.pushState(null, null, anchor.href);
|
||||
loadView();
|
||||
@ -28,7 +30,9 @@ function router(event) {
|
||||
}
|
||||
function navigator(event) {
|
||||
event.preventDefault();
|
||||
const anchor = event.path.find((anchor) => anchor.nodeName === 'A'),
|
||||
const anchor = event.path
|
||||
? event.path.find((anchor) => anchor.nodeName === 'A')
|
||||
: event.target,
|
||||
hash = anchor.getAttribute('href').slice(1);
|
||||
document.getElementById(hash).scrollIntoView(true);
|
||||
document.documentElement.scrollTop = 0;
|
||||
|
@ -32,7 +32,7 @@ const customClasses = {
|
||||
? 'bg-tag text-tag-text hover:bg-interactive-hover border border-divider'
|
||||
: `bg-${color}-tag text-${color}-tag-text border border-${color}-text hover:bg-${color}-text`
|
||||
} flex items-center rounded-full mt-3 shadow-md cursor-pointer`,
|
||||
'notification-text': apply`font-semibold mx-2 flex-auto`,
|
||||
'notification-text': apply`font-semibold text-xs mx-2 flex-auto`,
|
||||
'notification-icon': apply`fill-current opacity-75 h-4 w-4 mx-2`,
|
||||
'body-container': apply`flex w-full h-full overflow-hidden`,
|
||||
'content-container': apply`h-full w-full-96`,
|
||||
|
@ -7,37 +7,44 @@
|
||||
'use strict';
|
||||
|
||||
async function focusMenu() {
|
||||
const tabs = await chrome.tabs.query({ windowId: chrome.windows.WINDOW_ID_CURRENT }),
|
||||
url = chrome.runtime.getURL('repo/menu@a6621988-551d-495a-97d8-3c568bca2e9e/menu.html'),
|
||||
menu = tabs.find((tab) => tab.url.startsWith(url));
|
||||
if (menu) {
|
||||
chrome.tabs.highlight({ 'tabs': menu.index });
|
||||
} else chrome.tabs.create({ url });
|
||||
chrome.tabs.query({ windowId: chrome.windows.WINDOW_ID_CURRENT }, (tabs) => {
|
||||
const url = chrome.runtime.getURL(
|
||||
'repo/menu@a6621988-551d-495a-97d8-3c568bca2e9e/menu.html'
|
||||
),
|
||||
menu = tabs.find((tab) => tab.url.startsWith(url));
|
||||
if (menu) {
|
||||
chrome.tabs.highlight({ 'tabs': menu.index });
|
||||
} else chrome.tabs.create({ url });
|
||||
});
|
||||
}
|
||||
chrome.action.onClicked.addListener(focusMenu);
|
||||
chrome.browserAction.onClicked.addListener(focusMenu);
|
||||
|
||||
async function focusNotion() {
|
||||
const tabs = await chrome.tabs.query({ windowId: chrome.windows.WINDOW_ID_CURRENT }),
|
||||
notion = tabs.find((tab) => {
|
||||
chrome.tabs.query({ windowId: chrome.windows.WINDOW_ID_CURRENT }, (tabs) => {
|
||||
const notion = tabs.find((tab) => {
|
||||
const url = new URL(tab.url),
|
||||
matches = url.host.endsWith('.notion.so') || url.host.endsWith('.notion.site');
|
||||
return matches;
|
||||
});
|
||||
if (notion) {
|
||||
chrome.tabs.highlight({ 'tabs': notion.index });
|
||||
} else chrome.tabs.create({ url: 'https://notion.so/' });
|
||||
if (notion) {
|
||||
chrome.tabs.highlight({ 'tabs': notion.index });
|
||||
} else chrome.tabs.create({ url: 'https://notion.so/' });
|
||||
});
|
||||
}
|
||||
|
||||
async function reload() {
|
||||
const tabs = await chrome.tabs.query({ windowId: chrome.windows.WINDOW_ID_CURRENT }),
|
||||
menu = chrome.runtime.getURL('repo/menu@a6621988-551d-495a-97d8-3c568bca2e9e/menu.html');
|
||||
tabs.forEach((tab) => {
|
||||
const url = new URL(tab.url),
|
||||
matches =
|
||||
url.host.endsWith('.notion.so') ||
|
||||
url.host.endsWith('.notion.site') ||
|
||||
tab.url.startsWith(menu);
|
||||
if (matches) chrome.tabs.reload(tab.id);
|
||||
chrome.tabs.query({ windowId: chrome.windows.WINDOW_ID_CURRENT }, (tabs) => {
|
||||
const menu = chrome.runtime.getURL(
|
||||
'repo/menu@a6621988-551d-495a-97d8-3c568bca2e9e/menu.html'
|
||||
);
|
||||
tabs.forEach((tab) => {
|
||||
const url = new URL(tab.url),
|
||||
matches =
|
||||
url.host.endsWith('.notion.so') ||
|
||||
url.host.endsWith('.notion.site') ||
|
||||
tab.url.startsWith(menu);
|
||||
if (matches) chrome.tabs.reload(tab.id);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user