Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions packages/chrome-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
34 changes: 20 additions & 14 deletions packages/chrome-plugin/src/contentScript/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import '@webcomponents/custom-elements';
import $ from 'jquery';
import { isVisible, LintFramework, leafNodes } from 'lint-framework';
import ProtocolClient from '../ProtocolClient';

Expand All @@ -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) ||
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might still be incorrect.

<textarea> that is below the fold on a static page will be skipped over if it will not appear in the viewport within the first second.

A more compatible replacement could be https://youmightnotneedjquery.com/#is_visible

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)) {
Expand All @@ -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) {
Expand Down
23 changes: 0 additions & 23 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading