Conversation
Remove necessity of having query to allow "searches" without input
Add %PAGE_ORIGIN_NO_ENCODING parameter
Pull from original add-on
# Conflicts: # README.md
This file provides architectural guidance and development context for Claude Code when working with the Selection Search extension codebase.
Added note that this is a fork of the original Selection Search extension by Pitmairen, with links to both repositories.
Add a new user-configurable option 'allow_engines_without_selection' that allows the popup to be activated without text selection. This enables using the extension as a link collection tool for quick navigation. When enabled (default: OFF): - Inline popup activators show popup even without text selection - Toolbar popup works without entering query text - Context menu shows all engines in both 'selection' and 'page' contexts - All search engines appear regardless of having %s placeholder - Engines with %s search for empty string; engines without %s navigate directly Implementation: - Add option to storage defaults (background/storage.js) - Update all popup activators to check the option (popup/activators.js) - Make toolbar hasQuery() conditional (browseraction/popup.js) - Add 'page' context to context menu items when enabled (background/contextmenu.js) - Add UI checkbox in options page (options/options.html) - Update documentation about %s being optional The option is automatically included in export/import functionality. Default is OFF to maintain backward compatibility with existing users.
The option was added to storage and UI but wasn't connected to the save/load functions in options.js, causing it to always stay false. - Add option to load function (line 383) - Add option to save function (line 650) This fixes the issue where enabling the checkbox had no effect.
Version 0.9.9 adds the optional 'allow_engines_without_selection' feature: - Popup can be activated without text selection when enabled - Useful for using extension as link collection tool - Disabled by default for backward compatibility - Context menu appears on page context when enabled
- Remove CLAUDE.md (fork-specific documentation) - Remove 'Installation for Chrome' section from README (fork-specific) - Remove 'Configuration' section from README (SAP-specific)
These files are for local testing only and not part of the feature.
Pitmairen
left a comment
There was a problem hiding this comment.
Found a couple of issues when testing in Chrome.
options/options.html
Outdated
| <h4 class="subsection-heading" id="head-allow-engines-without-selection">Allow engines without selection</h4> | ||
| <div class="subsection"> | ||
| <p class="info"> | ||
| Enable this option to allow the popup to be activated without selecting text first. | ||
| This is useful for using the extension as a link collection tool for quick navigation to frequently | ||
| used URLs. When enabled, ALL search engines will appear in popups and context menus even when no text | ||
| is selected. Engines with %s will search for an empty string; engines without %s will navigate directly. | ||
| </p> | ||
| <p class="section-option"> | ||
| <label for="opt-allow-engines-without-selection">Allow engines without selection</label> | ||
| <input id="opt-allow-engines-without-selection" type="checkbox" name="allow-engines-without-selection" /> | ||
| </p> | ||
| </div> | ||
|
|
||
|
|
There was a problem hiding this comment.
I think it makes more sense to move this option into the "Other options" section at the bottom of the settings page, as this is a global option that affects all menu types.
There was a problem hiding this comment.
Nice suggestion. Done.
|
|
||
|
|
||
| if (!_this.hasSelection() || e.button != _options.button) | ||
| if (!_this.popupShouldOpen(e)) |
There was a problem hiding this comment.
I get the following error from the ClickActivator when the new option is enabled and clicking on the page body when there is no active selection.
selection_util.js:38 Uncaught IndexSizeError: Failed to execute 'getRangeAt' on 'Selection': 0 is not a valid index.
at SelectionUtil.getSelectionRect (selection_util.js:38:43)
at SelectionUtil.isPointOnSelection (selection_util.js:50:25)
at Activator.isPointOnSelection (activators.js:26:31)
at HTMLDocument.<anonymous> (activators.js:119:34)
SelectionUtil.getSelectionRect @ selection_util.js:38
SelectionUtil.isPointOnSelection @ selection_util.js:50
Activator.isPointOnSelection @ activators.js:26
(anonymous) @ activators.js:119
selection_util.js:38 Uncaught IndexSizeError: Failed to execute 'getRangeAt' on 'Selection': 0 is not a valid index.
at SelectionUtil.getSelectionRect (selection_util.js:38:43)
at SelectionUtil.isPointOnSelection (selection_util.js:50:25)
at Activator.isPointOnSelection (activators.js:26:31)
at HTMLDocument.<anonymous> (activators.js:119:34)
SelectionUtil.getSelectionRect @ selection_util.js:38
SelectionUtil.isPointOnSelection @ selection_util.js:50
Activator.isPointOnSelection @ activators.js:26
(anonymous) @ activators.js:119
selection_util.js:38 Uncaught IndexSizeError: Failed to execute 'getRangeAt' on 'Selection': 0 is not a valid index.
at SelectionUtil.getSelectionRect (selection_util.js:38:43)
at SelectionUtil.isPointOnSelection (selection_util.js:50:25)
at Activator.isPointOnSelection (activators.js:26:31)
at HTMLDocument.<anonymous> (activators.js:119:34)
SelectionUtil.getSelectionRect @ selection_util.js:38
SelectionUtil.isPointOnSelection @ selection_util.js:50
Activator.isPointOnSelection @ activators.js:26
(anonymous) @ activators.js:119
There is a similar issue from the call to isPointOnSelection inside the _disableEvent function inside the base Activator function when clicking on links.
selection_util.js:38 Uncaught IndexSizeError: Failed to execute 'getRangeAt' on 'Selection': 0 is not a valid index.
at SelectionUtil.getSelectionRect (selection_util.js:38:43)
at SelectionUtil.isPointOnSelection (selection_util.js:50:25)
at Activator.isPointOnSelection (activators.js:26:31)
at HTMLDocument.<anonymous> (activators.js:119:34)
SelectionUtil.getSelectionRect @ selection_util.js:38
SelectionUtil.isPointOnSelection @ selection_util.js:50
Activator.isPointOnSelection @ activators.js:26
(anonymous) @ activators.js:119
selection_util.js:38 Uncaught IndexSizeError: Failed to execute 'getRangeAt' on 'Selection': 0 is not a valid index.
at SelectionUtil.getSelectionRect (selection_util.js:38:43)
at SelectionUtil.isPointOnSelection (selection_util.js:50:25)
at Activator.isPointOnSelection (activators.js:26:31)
at HTMLAnchorElement._disableEvent (activators.js:62:18)
SelectionUtil.getSelectionRect @ selection_util.js:38
SelectionUtil.isPointOnSelection @ selection_util.js:50
Activator.isPointOnSelection @ activators.js:26
_disableEvent @ activators.js:62
selection_util.js:38 Uncaught IndexSizeError: Failed to execute 'getRangeAt' on 'Selection': 0 is not a valid index.
at SelectionUtil.getSelectionRect (selection_util.js:38:43)
at SelectionUtil.isPointOnSelection (selection_util.js:50:25)
at Activator.isPointOnSelection (activators.js:26:31)
at HTMLAnchorElement._disableEvent (activators.js:62:18)
SelectionUtil.getSelectionRect @ selection_util.js:38
SelectionUtil.isPointOnSelection @ selection_util.js:50
Activator.isPointOnSelection @ activators.js:26
_disableEvent @ activators.js:62
There was a problem hiding this comment.
Haven't seen. Thanks for highlighting
There was a problem hiding this comment.
The crash is gone, but the popup still doesn't work with the default click activator. Nothing happens when clicking on the page without a selection.
- Move "Allow engines without selection" option from Advanced Settings to Other Options section - This is a global option affecting all menu types, so it belongs in Other Options - Update reference text to reflect new location - Fix IndexSizeError when clicking without text selection - Add check for selection.rangeCount before calling getRangeAt(0) in getSelectionRect() - Early return false in isPointOnSelection() when rect is undefined - Prevents crash when clicking page/links with allow_engines_without_selection enabled
|
Fixed all the comments |
|
|
||
|
|
||
| if (!_this.hasSelection() || !_is_keyboard_combo_activated() || _mouseButton != e.button) | ||
| if (!_this.popupShouldOpen(e)) |
There was a problem hiding this comment.
This changes the behaviour of this activator, as it no longer uses the mouse button configured on the KeyAndMouseActivator, it uses the button configured for the ClickActivator instead.
The issue is the button check in popupShouldOpen, it doesn't check the _mouseButton value.
The problem in popupShouldOpen already existed before your change, but because popupShouldOpen wasn't used here before it didn't cause any noticeable issues.
Fixing popupShouldOpen should solve this.
|
|
||
|
|
||
| if (!_this.hasSelection() || e.button != _options.button) | ||
| if (!_this.popupShouldOpen(e)) |
There was a problem hiding this comment.
The crash is gone, but the popup still doesn't work with the default click activator. Nothing happens when clicking on the page without a selection.
Add Optional Selection Requirement Feature
Summary
This PR adds a new user-configurable option
allow_engines_without_selectionthat enables using the extension as a link collection tool for quick navigation without requiring text selectionfirst.
Motivation
Users who want to use the extension for quick access to frequently used URLs (e.g., multiple test environment instances like
https://test1.example.com/dashboard,https://test2.example.com/dashboard) currently must select text first to activate the popup. This PR makes text selection optional.Changes
New Option
allow_engines_without_selectionfalse(maintains current behavior for existing users)Behavior When Enabled
Files Modified (6 files, ~70 lines changed)
background/storage.js- Added option to defaultsbackground/contextmenu.js- Added 'page' context support when option enabledbrowseraction/popup.js- MadehasQuery()conditional on optionpopup/activators.js- Updated all activators to check optionoptions/options.html- Added UI checkbox and updated documentationoptions/options.js- Connected save/load functionsImplementation Details
The implementation is minimal and non-invasive:
Testing
Tested scenarios:
Backward Compatibility
Use Cases
Version
Bumped to 0.9.9 with changelog entry.
Notes