Skip to content

Commit ee5b787

Browse files
committed
feat: introduce selector auto-detector module for managing element detection, recovery, and settings
1 parent be18f15 commit ee5b787

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

modules/selector-auto-detector/index.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -93,23 +93,23 @@ window.OneClickPromptsSelectorAutoDetector = {
9393
// Readable name for the type
9494
const typeName = type === 'editor' ? 'Text input area' : 'send button';
9595

96-
// If heuristics are disabled, still notify the user but skip the scan.
96+
// Unified message logic
97+
const statusSuffix = heuristicsAllowed ? "Trying to find it..." : "Auto-detect is off.";
98+
const toastType = heuristicsAllowed ? 'info' : 'error';
99+
100+
if (window.showToast) {
101+
window.showToast(`OneClickPrompts: ${typeName} not found. ${statusSuffix}`, toastType);
102+
} else {
103+
console.warn(`OneClickPrompts: ${typeName} not found. ${statusSuffix}`);
104+
}
105+
106+
// If heuristics are disabled, stop here.
97107
if (!heuristicsAllowed) {
98108
logConCgp(`[SelectorAutoDetector] Heuristics disabled for ${type}; skipping recovery.`);
99-
if (window.showToast) {
100-
window.showToast(`OneClickPrompts: ${typeName} not found. Auto-detect is off.`, 'error');
101-
}
102109
s.recovering = false;
103110
return null;
104111
}
105112

106-
// Notify user
107-
if (window.showToast) {
108-
window.showToast(`OneClickPrompts: ${typeName} not found. Trying to find it...`, 'info');
109-
} else {
110-
console.warn(`OneClickPrompts: ${typeName} not found. Analyzing page structure...`);
111-
}
112-
113113
const site = window.InjectionTargetsOnWebsite?.activeSite || 'Unknown';
114114
const heuristics = window.OneClickPromptsSiteHeuristics?.resolve
115115
? window.OneClickPromptsSiteHeuristics.resolve(site)

0 commit comments

Comments
 (0)