From 2971a1d53bb0af9732bbaf0c51f921f169280d94 Mon Sep 17 00:00:00 2001 From: EnixCoda Date: Sun, 16 Feb 2020 00:13:00 +0800 Subject: [PATCH] feat: inject stylesheet into DOM --- src/content.tsx | 10 ++++++++++ src/manifest.json | 25 +++++-------------------- 2 files changed, 15 insertions(+), 20 deletions(-) diff --git a/src/content.tsx b/src/content.tsx index 2a9c318..265a6bb 100644 --- a/src/content.tsx +++ b/src/content.tsx @@ -18,3 +18,13 @@ if (document.readyState === 'loading') { } else { init() } + +// injects a copy of stylesheets so that other extensions(e.g. dark reader) could read +function injectStyles(url: string) { + var linkElement = document.createElement('link') + linkElement.rel = 'stylesheet' + linkElement.setAttribute('href', url) + document.head.appendChild(linkElement) +} + +injectStyles(browser.extension.getURL('content.css')) diff --git a/src/manifest.json b/src/manifest.json index f976c63..a0396a6 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -8,27 +8,12 @@ "128": "icons/Gitako-128x128.png" }, "homepage_url": "https://github.com/EnixCoda/Gitako", - "permissions": [ - "storage", - "*://*.github.com/*", - "*://*.sentry.io/*" - ], - "web_accessible_resources": [ - "icons/vscode/*" - ], + "permissions": ["storage", "*://*.github.com/*", "*://*.sentry.io/*"], + "web_accessible_resources": ["icons/vscode/*", "content.css"], "content_scripts": [ { - "matches": [ - "https://github.com/*" - ], - "css": [ - "content.css" - ], - "js": [ - "firefox-shim.js", - "browser-polyfill.js", - "content.js" - ] + "matches": ["https://github.com/*"], + "js": ["firefox-shim.js", "browser-polyfill.js", "content.js"] } ] -} \ No newline at end of file +}