Skip to content

Offline, privacy-first grammar checker. Fast, open-source, Rust-powered

feat(chrome-ext): enable by default on WordPress pages (#2065)

Elijah Potterbc25d103dba6
diff --git a/packages/chrome-plugin/src/contentScript/index.ts b/packages/chrome-plugin/src/contentScript/index.ts
index c23b54d3c..574dc24a9 100644
--- a/packages/chrome-plugin/src/contentScript/index.ts
+++ b/packages/chrome-plugin/src/contentScript/index.ts
@@ -1,7 +1,12 @@
import '@webcomponents/custom-elements';
import { isVisible, LintFramework, leafNodes } from 'lint-framework';
+import isWordPress from '../isWordPress';
import ProtocolClient from '../ProtocolClient';
+if (isWordPress()) {
+ ProtocolClient.setDomainEnabled(window.location.hostname, true);
+}
+
const fw = new LintFramework((text, domain) => ProtocolClient.lint(text, domain), {
ignoreLint: (hash) => ProtocolClient.ignoreHash(hash),
getActivationKey: () => ProtocolClient.getActivationKey(),
diff --git a/packages/chrome-plugin/src/isWordPress.ts b/packages/chrome-plugin/src/isWordPress.ts
new file mode 100644
index 000000000..d93978483
--- /dev/null
+++ b/packages/chrome-plugin/src/isWordPress.ts
@@ -0,0 +1,12 @@
+/** Does a rough estimate of whether the current page is a WordPress page. */
+export default function isWordPress(): boolean {
+ if (document.querySelector('meta[name="generator"][content*="WordPress"]')) {
+ return true;
+ }
+
+ if (document.querySelector('link[rel="https://api.w.org/"][href]')) {
+ return true;
+ }
+
+ return false;
+}