Skip to content

Commit 08eccaf

Browse files
committed
feat: Implement heuristic-based selector auto-detection with failure tracking and site-specific overrides.
1 parent ee5b787 commit 08eccaf

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

modules/selector-auto-detector/base-heuristics.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,14 @@ window.OneClickPromptsSelectorAutoDetectorBase = {
177177
score += 1;
178178
}
179179

180+
// E. Negative Scoring (Penalize known non-send actions)
181+
const negativeKeywords = ['stop', 'group', 'cancel', 'attach', 'upload', 'file', 'image', 'voice', 'mic'];
182+
const matchesNegative = (str) => negativeKeywords.some(k => str.includes(k));
183+
184+
if (matchesNegative(ariaLabel) || matchesNegative(title) || matchesNegative(testId)) {
185+
score -= 50; // Heavy penalty to ensure it's not picked
186+
}
187+
180188
return { el, score };
181189
});
182190

modules/selector-auto-detector/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,9 @@ window.OneClickPromptsSelectorAutoDetector = {
115115
? window.OneClickPromptsSiteHeuristics.resolve(site)
116116
: window.OneClickPromptsSelectorAutoDetectorBase;
117117

118+
// Wait a moment for the UI to stabilize (e.g. if the button is just about to appear)
119+
await new Promise(resolve => setTimeout(resolve, 400));
120+
118121
// Run Heuristics
119122
let result = null;
120123
if (type === 'editor') {

0 commit comments

Comments
 (0)