Offline, privacy-first grammar checker. Fast, open-source, Rust-powered
feat(chrome-ext): enable on all Substack sites (#2800)
Elijah Potter67eb477568b6
diff --git a/packages/chrome-plugin/src/contentScript/index.ts b/packages/chrome-plugin/src/contentScript/index.tsindex 1764e1f1d..341ac0430 100644--- a/packages/chrome-plugin/src/contentScript/index.ts+++ b/packages/chrome-plugin/src/contentScript/index.ts@@ -6,10 +6,11 @@ import {leafNodes,type UnpackedLint,} from 'lint-framework';+import isSubstack from '../isSubstack';import isWordPress from '../isWordPress';import ProtocolClient from '../ProtocolClient';-if (isWordPress()) {+if (isWordPress() || isSubstack()) {ProtocolClient.setDomainEnabled(window.location.hostname, true, false);}diff --git a/packages/chrome-plugin/src/isSubstack.ts b/packages/chrome-plugin/src/isSubstack.tsnew file mode 100644index 000000000..1998a8fd7--- /dev/null+++ b/packages/chrome-plugin/src/isSubstack.ts@@ -0,0 +1,22 @@+/** Does a rough estimate of whether the current page is a Substack page. */+export default function isSubstack(): boolean {+ const hostname = window.location.hostname.toLowerCase();++ if (hostname === 'substack.com' || hostname.endsWith('.substack.com')) {+ return true;+ }++ if (document.querySelector('link[rel="preconnect"][href*="substackcdn.com"]')) {+ return true;+ }++ if (document.querySelector('meta[property="og:title"][content*="| Substack"]')) {+ return true;+ }++ if (document.querySelector('meta[name="description"][content*="a Substack publication"]')) {+ return true;+ }++ return false;+}