Skip to content

Commit b4b46ff

Browse files
refactor(chrome-ext): drop jquery dependency (#2052)
Co-authored-by: Elijah Potter <[email protected]>
1 parent 50dbfcc commit b4b46ff

File tree

3 files changed

+20
-39
lines changed

3 files changed

+20
-39
lines changed

packages/chrome-plugin/package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
"@playwright/test": "^1.52.0",
3030
"@sveltejs/vite-plugin-svelte": "^4.0.0",
3131
"@types/chrome": "^0.0.246",
32-
"@types/jquery": "^3.5.32",
3332
"@types/lodash-es": "^4.17.12",
3433
"@types/node": "catalog:",
3534
"flowbite": "^3.1.2",
@@ -52,7 +51,6 @@
5251
"@tailwindcss/vite": "^4.1.4",
5352
"@webcomponents/custom-elements": "^1.6.0",
5453
"harper.js": "workspace:*",
55-
"jquery": "^3.7.1",
5654
"lint-framework": "workspace:*",
5755
"lodash-es": "^4.17.21",
5856
"lru-cache": "^11.1.0",

packages/chrome-plugin/src/contentScript/index.ts

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import '@webcomponents/custom-elements';
2-
import $ from 'jquery';
32
import { isVisible, LintFramework, leafNodes } from 'lint-framework';
43
import ProtocolClient from '../ProtocolClient';
54

@@ -19,24 +18,31 @@ const keepAliveCallback = () => {
1918
keepAliveCallback();
2019

2120
function scan() {
22-
$('textarea:visible').each(function () {
23-
if (this.getAttribute('data-enable-grammarly') == 'false' || this.disabled || this.readOnly) {
21+
document.querySelectorAll<HTMLTextAreaElement>('textarea').forEach((element) => {
22+
if (
23+
!isVisible(element) ||
24+
element.getAttribute('data-enable-grammarly') === 'false' ||
25+
element.disabled ||
26+
element.readOnly
27+
) {
2428
return;
2529
}
2630

27-
fw.addTarget(this as HTMLTextAreaElement);
31+
fw.addTarget(element);
2832
});
2933

30-
$('input[type="text"][spellcheck="true"]').each(function () {
31-
if (this.disabled || this.readOnly) {
32-
return;
33-
}
34+
document
35+
.querySelectorAll<HTMLInputElement>('input[type="text"][spellcheck="true"]')
36+
.forEach((element) => {
37+
if (element.disabled || element.readOnly) {
38+
return;
39+
}
3440

35-
fw.addTarget(this as HTMLInputElement);
36-
});
41+
fw.addTarget(element);
42+
});
3743

38-
$('[data-testid="gutenberg-editor"]').each(function () {
39-
const leafs = leafNodes(this);
44+
document.querySelectorAll('[data-testid="gutenberg-editor"]').forEach((element) => {
45+
const leafs = leafNodes(element);
4046

4147
for (const leaf of leafs) {
4248
if (!isVisible(leaf)) {
@@ -47,8 +53,8 @@ function scan() {
4753
}
4854
});
4955

50-
$('[contenteditable="true"],[contenteditable]').each(function () {
51-
const leafs = leafNodes(this);
56+
document.querySelectorAll('[contenteditable="true"],[contenteditable]').forEach((element) => {
57+
const leafs = leafNodes(element);
5258

5359
for (const leaf of leafs) {
5460
if (leaf.parentElement?.closest('[contenteditable="false"],[disabled],[readonly]') != null) {

pnpm-lock.yaml

Lines changed: 0 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)