Offline, privacy-first grammar checker. Fast, open-source, Rust-powered
refactor(chrome-ext): drop jquery dependency (#2052)
Indrek Ardelb4b46ff12bfe
diff --git a/packages/chrome-plugin/package.json b/packages/chrome-plugin/package.jsonindex 84dc2c170..80dbef669 100644--- a/packages/chrome-plugin/package.json+++ b/packages/chrome-plugin/package.json@@ -29,7 +29,6 @@"@playwright/test": "^1.52.0","@sveltejs/vite-plugin-svelte": "^4.0.0","@types/chrome": "^0.0.246",- "@types/jquery": "^3.5.32","@types/lodash-es": "^4.17.12","@types/node": "catalog:","flowbite": "^3.1.2",@@ -52,7 +51,6 @@"@tailwindcss/vite": "^4.1.4","@webcomponents/custom-elements": "^1.6.0","harper.js": "workspace:*",- "jquery": "^3.7.1","lint-framework": "workspace:*","lodash-es": "^4.17.21","lru-cache": "^11.1.0",diff --git a/packages/chrome-plugin/src/contentScript/index.ts b/packages/chrome-plugin/src/contentScript/index.tsindex 5d5b9e4a0..9f008d9cf 100644--- a/packages/chrome-plugin/src/contentScript/index.ts+++ b/packages/chrome-plugin/src/contentScript/index.ts@@ -1,5 +1,4 @@import '@webcomponents/custom-elements';-import $ from 'jquery';import { isVisible, LintFramework, leafNodes } from 'lint-framework';import ProtocolClient from '../ProtocolClient';@@ -19,24 +18,31 @@ const keepAliveCallback = () => {keepAliveCallback();function scan() {- $('textarea:visible').each(function () {- if (this.getAttribute('data-enable-grammarly') == 'false' || this.disabled || this.readOnly) {+ document.querySelectorAll<HTMLTextAreaElement>('textarea').forEach((element) => {+ if (+ !isVisible(element) ||+ element.getAttribute('data-enable-grammarly') === 'false' ||+ element.disabled ||+ element.readOnly+ ) {return;}- fw.addTarget(this as HTMLTextAreaElement);+ fw.addTarget(element);});- $('input[type="text"][spellcheck="true"]').each(function () {- if (this.disabled || this.readOnly) {- return;- }+ document+ .querySelectorAll<HTMLInputElement>('input[type="text"][spellcheck="true"]')+ .forEach((element) => {+ if (element.disabled || element.readOnly) {+ return;+ }- fw.addTarget(this as HTMLInputElement);- });+ fw.addTarget(element);+ });- $('[data-testid="gutenberg-editor"]').each(function () {- const leafs = leafNodes(this);+ document.querySelectorAll('[data-testid="gutenberg-editor"]').forEach((element) => {+ const leafs = leafNodes(element);for (const leaf of leafs) {if (!isVisible(leaf)) {@@ -47,8 +53,8 @@ function scan() {}});- $('[contenteditable="true"],[contenteditable]').each(function () {- const leafs = leafNodes(this);+ document.querySelectorAll('[contenteditable="true"],[contenteditable]').forEach((element) => {+ const leafs = leafNodes(element);for (const leaf of leafs) {if (leaf.parentElement?.closest('[contenteditable="false"],[disabled],[readonly]') != null) {diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex d55e5da50..df612a618 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -49,9 +49,6 @@ importers:harper.js:specifier: workspace:*version: link:../harper.js- jquery:- specifier: ^3.7.1- version: 3.7.1lint-framework:specifier: workspace:*version: link:../lint-framework@@ -77,9 +74,6 @@ importers:'@types/chrome':specifier: ^0.0.246version: 0.0.246- '@types/jquery':- specifier: ^3.5.32- version: 3.5.32'@types/lodash-es':specifier: ^4.17.12version: 4.17.12@@ -3320,9 +3314,6 @@ packages:'@types/[email protected]':resolution: {integrity: sha512-DVOfk9FaClQfNFpSfaML15jjB5cjffDMvjtph525sroR5BEAW2uKnTOYUTqTFuZFjNvH0T5XMIydvIctnUKufw==}- '@types/[email protected]':- resolution: {integrity: sha512-b9Xbf4CkMqS02YH8zACqN1xzdxc3cO735Qe5AbSUFmyOiaWAbcpqh9Wna+Uk0vgACvoQHpWDg2rGdHkYPLmCiQ==}-'@types/[email protected]':resolution: {integrity: sha512-k4MGaQl5TGo/iipqb2UDG2UwjXziSWkh0uysQelTlJpX1qGlpUZYm8PnO4DxG1qBomtJUdYJ6qR6xdIah10JLg==}@@ -3412,9 +3403,6 @@ packages:'@types/[email protected]':resolution: {integrity: sha512-rvqefdp2rvIA6wiomMgKWd2UZNPe6LM2EV5AuY3CPQJF+8TbdrL5TjYdMf0VAjGczzlkH4l1NjDkihwbj3Xodw==}- '@types/[email protected]':- resolution: {integrity: sha512-xzLEyKB50yqCUPUJkIsrVvoWNfFUbIZI+RspLWt8u+tIW/BetMBZtgV2LY/2o+tYH8dRvQ+eoPf3NdhQCcLE2w==}-'@types/[email protected]':resolution: {integrity: sha512-MK9V6NzAS1+Ud7JV9lJLFqW85VbC9dq3LmwZCuBe4wBDgKC0Kj/jd8Xl+nSviU+Qc3+m7umHHyHg//2KSa0a0Q==}@@ -7401,9 +7389,6 @@ packages:resolution: {integrity: sha512-WZzeDOEtTOBK4Mdsar0IqEU5sMr3vSV2RqkAIzUEV2BHnUfKGyswWFPFwK5EeDo93K3FohSHbLAjj0s1Wzd+dg==}- resolution: {integrity: sha512-m4avr8yL8kmFN8psrbFFFmB/If14iN5o9nw/NgnnM+kybDJpRsAynV2BsfpTYrTRysYUdADVD7CkUUizgkpLfg==}-resolution: {integrity: sha512-c80Qupofp43y4cJ7+8TTDN/AsDwLi5oOm/plBrWI+iQt485vKXCco+yVmOwEgdo9VOdsYTuV0UlTeetVPTriXA==}engines: {node: '>=12'}@@ -15204,10 +15189,6 @@ snapshots:'@types/[email protected]': {}- '@types/[email protected]':- dependencies:- '@types/sizzle': 2.3.9-'@types/[email protected]': {}'@types/[email protected]':@@ -15294,8 +15275,6 @@ snapshots:dependencies:'@types/node': 22.13.10- '@types/[email protected]': {}-'@types/[email protected]':dependencies:'@types/node': 22.13.10@@ -20864,8 +20843,6 @@ snapshots:- [email protected]: {}-