diff --git a/src/intercept.ts b/src/intercept.ts index a81efdb..2c7a30b 100644 --- a/src/intercept.ts +++ b/src/intercept.ts @@ -15,6 +15,7 @@ import * as Github from './sites/github'; import * as LinkedIn from './sites/linkedin'; import * as Instagram from './sites/instagram'; import * as YouTube from './sites/youtube'; +import * as Substack from './sites/substack'; import { createStore, Store } from './store'; const store = createStore(); @@ -31,6 +32,8 @@ export function eradicate(store: Store) { Github.eradicate(store); } else if (LinkedIn.checkSite()) { LinkedIn.eradicate(store); + } else if (Substack.checkSite()) { + Substack.eradicate(store) } else if (YouTube.checkSite()) { YouTube.eradicate(store); } else if (Instagram.checkSite()) { diff --git a/src/manifest-chrome.json b/src/manifest-chrome.json index 2ac0b09..72eb2a4 100644 --- a/src/manifest-chrome.json +++ b/src/manifest-chrome.json @@ -2,8 +2,11 @@ "name": "News Feed Eradicator", "version": "2.3.1", "description": "Eradicate social media noise by replacing your entire news feed with an inspiring quote", - "manifest_version": 3, - "permissions": ["storage", "scripting"], + "manifest_version": 4, + "permissions": [ + "storage", + "scripting" + ], "optional_host_permissions": [ "http://www.facebook.com/*", "https://www.facebook.com/*", @@ -24,7 +27,8 @@ "https://www.github.com/*", "https://github.com/*", "http://www.instagram.com/*", - "https://www.instagram.com/*" + "https://www.instagram.com/*", + "https://substack.com/*" ], "action": { "default_icon": { diff --git a/src/manifest.json b/src/manifest.json index cb228d5..c469217 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -3,7 +3,9 @@ "version": "2.2.7", "description": "Eradicate social media noise by replacing your entire news feed with an inspiring quote", "manifest_version": 2, - "permissions": ["storage"], + "permissions": [ + "storage" + ], "optional_permissions": [ "http://www.facebook.com/*", "https://www.facebook.com/*", @@ -24,7 +26,8 @@ "https://www.github.com/*", "https://github.com/*", "http://www.instagram.com/*", - "https://www.instagram.com/*" + "https://www.instagram.com/*", + "https://substack.com/*" ], "browser_action": { "default_icon": { diff --git a/src/sites/index.ts b/src/sites/index.ts index ebbdd0d..7d92387 100644 --- a/src/sites/index.ts +++ b/src/sites/index.ts @@ -11,7 +11,8 @@ export type SiteId = | 'linkedin' | 'youtube' | 'instagram' - | 'github'; + | 'github' + | 'substack'; export const Sites: Record = { facebook: { @@ -97,6 +98,12 @@ export const Sites: Record = { origins: ['https://github.com/*'], css: githubCss, }, + substack: { + label: 'Substack', + domain: ['substack.com'], + paths: ['/', '/home'], + origins: ['https://substack.com/*'], + }, }; export type Site = { diff --git a/src/sites/instagram.ts b/src/sites/instagram.ts index 3b87c32..c958aec 100644 --- a/src/sites/instagram.ts +++ b/src/sites/instagram.ts @@ -1,7 +1,7 @@ import injectUI, { isAlreadyInjected } from '../lib/inject-ui'; import { isEnabled } from '../lib/is-enabled'; import { Store } from '../store'; -import {injectCSS} from "./shared"; +import { injectCSS } from "./shared"; export function checkSite(): boolean { return window.location.host.includes('instagram.com'); diff --git a/src/sites/substack.str.css b/src/sites/substack.str.css new file mode 100644 index 0000000..f9fc995 --- /dev/null +++ b/src/sites/substack.str.css @@ -0,0 +1,5 @@ +/* Substack */ +html:not([data-nfe-enabled='false']) div[aria-label='Notes feed'] div[class*="feedItem"] { + opacity: 0 !important; + pointer-events: none !important; +} \ No newline at end of file diff --git a/src/sites/substack.ts b/src/sites/substack.ts new file mode 100644 index 0000000..83df13e --- /dev/null +++ b/src/sites/substack.ts @@ -0,0 +1,33 @@ +import injectUI, { isAlreadyInjected } from '../lib/inject-ui'; +import { isEnabled } from '../lib/is-enabled'; +import { Store } from '../store'; +import { injectCSS } from "./shared"; + +export function checkSite(): boolean { + return window.location.host.includes('substack.com'); +} + +export function eradicate(store: Store) { + function eradicateRetry() { + injectCSS('substack'); + + const settings = store.getState().settings; + if (settings == null || !isEnabled(settings)) { + return; + } + + const container = document.querySelector('div[aria-label="Notes feed"]'); + if (container == null) { + return; + } + + // Add News Feed Eradicator quote/info panel + if (container && !isAlreadyInjected()) { + injectUI(container, store, { asFirstChild: true }); + } + } + + // This delay ensures that the elements have been created by Linkedin's + // scripts before we attempt to replace them + setInterval(eradicateRetry, 1000); +}