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