From fc8334a36aeb970f3d7d555362e54be3bc5930a2 Mon Sep 17 00:00:00 2001 From: Perry Mitchell Date: Sun, 7 Apr 2024 07:36:46 +0300 Subject: [PATCH] Improve input fill logic --- package-lock.json | 14 +++++++------- package.json | 2 +- source/shared/library/version.ts | 2 +- source/tab/services/formDetection.ts | 11 +++++++++-- source/tab/ui/launch.ts | 9 ++------- 5 files changed, 20 insertions(+), 18 deletions(-) diff --git a/package-lock.json b/package-lock.json index d6f68bd0..16fc11e2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,7 +17,7 @@ "@blueprintjs/popover2": "^1.14.11", "@blueprintjs/select": "^4.9.24", "@buttercup/channel-queue": "^1.4.0", - "@buttercup/locust": "^2.2.1", + "@buttercup/locust": "^2.3.1", "@buttercup/ui": "^6.2.2", "@types/chrome": "^0.0.251", "@types/ms": "^0.7.34", @@ -2082,9 +2082,9 @@ } }, "node_modules/@buttercup/locust": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/@buttercup/locust/-/locust-2.2.1.tgz", - "integrity": "sha512-tBOCS8bfuG2fGByTPR5V0EhQGieq4ewRHnfKlwzFsF3ZUKzc6/OvzKeH8JlmCnj90Y8nj4G3DDipMnbdv93a9g==", + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/@buttercup/locust/-/locust-2.3.1.tgz", + "integrity": "sha512-alAPWdOUPF9iEPcxZplYwmbdzR+ZYRpLU9bo7zZP4TY9eboIbhlasysOuZhzZoZdbqhS0/ORc3HpqruPxjY1qw==", "dev": true, "dependencies": { "eventemitter3": "^5.0.1", @@ -16269,9 +16269,9 @@ } }, "@buttercup/locust": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/@buttercup/locust/-/locust-2.2.1.tgz", - "integrity": "sha512-tBOCS8bfuG2fGByTPR5V0EhQGieq4ewRHnfKlwzFsF3ZUKzc6/OvzKeH8JlmCnj90Y8nj4G3DDipMnbdv93a9g==", + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/@buttercup/locust/-/locust-2.3.1.tgz", + "integrity": "sha512-alAPWdOUPF9iEPcxZplYwmbdzR+ZYRpLU9bo7zZP4TY9eboIbhlasysOuZhzZoZdbqhS0/ORc3HpqruPxjY1qw==", "dev": true, "requires": { "eventemitter3": "^5.0.1", diff --git a/package.json b/package.json index a9221265..f97a7106 100644 --- a/package.json +++ b/package.json @@ -63,7 +63,7 @@ "@blueprintjs/popover2": "^1.14.11", "@blueprintjs/select": "^4.9.24", "@buttercup/channel-queue": "^1.4.0", - "@buttercup/locust": "^2.2.1", + "@buttercup/locust": "^2.3.1", "@buttercup/ui": "^6.2.2", "@types/chrome": "^0.0.251", "@types/ms": "^0.7.34", diff --git a/source/shared/library/version.ts b/source/shared/library/version.ts index 167c5d47..3c772fda 100644 --- a/source/shared/library/version.ts +++ b/source/shared/library/version.ts @@ -1,4 +1,4 @@ // Do not edit this file - it is generated automatically at build time -export const BUILD_DATE = "2024-04-02"; +export const BUILD_DATE = "2024-04-06"; export const VERSION = "3.1.0"; diff --git a/source/tab/services/formDetection.ts b/source/tab/services/formDetection.ts index eb78ada2..d43ba4e7 100644 --- a/source/tab/services/formDetection.ts +++ b/source/tab/services/formDetection.ts @@ -1,4 +1,4 @@ -import { LoginTarget, getLoginTargets } from "@buttercup/locust"; +import { LoginTarget, LoginTargetFeature, getLoginTargets } from "@buttercup/locust"; import { attachLaunchButton } from "../ui/launch.js"; import { watchCredentialsOnTarget } from "./logins/watcher.js"; import { processTargetAutoLogin } from "./autoLogin.js"; @@ -7,10 +7,17 @@ import { getConfig } from "./config.js"; const TARGET_SEARCH_INTERVAL = 1000; +function filterLoginTarget(_: LoginTargetFeature, element: HTMLElement): boolean { + if (element.dataset.bcup === "attached") { + return false; + } + return true; +} + function onIdentifiedTarget(callback: (target: LoginTarget) => void) { const locatedForms = []; const findTargets = () => { - getLoginTargets() + getLoginTargets(document, filterLoginTarget) .filter((target) => locatedForms.includes(target.form) === false) .forEach((target) => { locatedForms.push(target.form); diff --git a/source/tab/ui/launch.ts b/source/tab/ui/launch.ts index 5ead1f77..9636eeb0 100644 --- a/source/tab/ui/launch.ts +++ b/source/tab/ui/launch.ts @@ -32,18 +32,13 @@ export function attachLaunchButton( if (buttonType === InputButtonType.LargeButton) { renderButtonStyle(input, () => onClick(input), tryToAttach, bounds); } else if (buttonType === InputButtonType.InnerIcon) { - renderInternalStyle(input, () => onClick(input), tryToAttach, bounds); + renderInternalStyle(input, () => onClick(input), bounds); } }; tryToAttach(); } -function renderInternalStyle( - input: HTMLInputElement, - onClick: () => void, - reattachCB: () => void, - inputBounds: DOMRect -) { +function renderInternalStyle(input: HTMLInputElement, onClick: () => void, inputBounds: DOMRect) { const bounds = inputBounds || input.getBoundingClientRect(); const { height } = bounds; const imageSize = height * 0.6;