Skip to content

Optional Selection Requirement#197

Merged
Pitmairen merged 51 commits intoPitmairen:masterfrom
CFR0901:feature/optional-selection-requirement
Apr 6, 2026
Merged

Optional Selection Requirement#197
Pitmairen merged 51 commits intoPitmairen:masterfrom
CFR0901:feature/optional-selection-requirement

Conversation

@CFR0901
Copy link
Copy Markdown
Contributor

@CFR0901 CFR0901 commented Mar 11, 2026

Add Optional Selection Requirement Feature

Summary

This PR adds a new user-configurable option allow_engines_without_selection that enables using the extension as a link collection tool for quick navigation without requiring text selection
first.

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

  • Name: allow_engines_without_selection
  • Default: false (maintains current behavior for existing users)
  • Location: Advanced Settings → "Allow engines without selection"
  • Export/Import: Automatically included in settings export/import

Behavior When Enabled

  • ✅ Inline popup activators show popup without text selection
  • ✅ Toolbar popup executes engines without requiring query text
  • ✅ Context menu appears on 'page' context (right-click anywhere)
  • ✅ ALL engines appear regardless of %s placeholder
  • ✅ Engines with %s search for empty string
  • ✅ Engines without %s navigate directly
  • ✅ Page variables (%PAGE_URL, etc.) work without %s

Files Modified (6 files, ~70 lines changed)

  1. background/storage.js - Added option to defaults
  2. background/contextmenu.js - Added 'page' context support when option enabled
  3. browseraction/popup.js - Made hasQuery() conditional on option
  4. popup/activators.js - Updated all activators to check option
  5. options/options.html - Added UI checkbox and updated documentation
  6. options/options.js - Connected save/load functions

Implementation Details

The implementation is minimal and non-invasive:

  • No filtering of engines based on %s presence - all engines always shown
  • Option only controls whether popup can be activated without selection
  • All existing functionality preserved when option is disabled (default)
  • No breaking changes to existing APIs or behavior

Testing

Tested scenarios:

  • ✅ Default behavior (option OFF) unchanged
  • ✅ Inline popup with all activators (click, auto, keyboard+mouse, double-click)
  • ✅ Toolbar popup without query text
  • ✅ Context menu in page context
  • ✅ Mixed engines (with/without %s, page variables, special actions)
  • ✅ Export/import preserves setting
  • ✅ Chrome sync works correctly

Backward Compatibility

  • ✅ Default is OFF - no behavior change for existing users
  • ✅ Old configs imported without the option default to OFF
  • ✅ No changes to existing APIs
  • ✅ All existing features work unchanged

Use Cases

  1. Link Collections: Quick access to test/staging/production environments
  2. Page Variables Only: Engines using only %PAGE_URL without %s
  3. Navigation Shortcuts: Static URLs for frequently visited pages
  4. Bookmarks Alternative: Search engines as organized bookmarks

Version

Bumped to 0.9.9 with changelog entry.

Notes

  • Context menu must be separately enabled via Menu Activation settings
  • The option name reflects what it does: allows engines (popup) without selection
  • Simple, clean implementation following existing patterns in the codebase

CFR0901 added 19 commits June 22, 2023 14:06
# 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.
Copy link
Copy Markdown
Owner

@Pitmairen Pitmairen left a comment

Choose a reason for hiding this comment

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

Found a couple of issues when testing in Chrome.

Comment thread options/options.html Outdated
Comment thread popup/activators.js
- 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
@CFR0901
Copy link
Copy Markdown
Contributor Author

CFR0901 commented Mar 18, 2026

Fixed all the comments

@CFR0901 CFR0901 requested a review from Pitmairen March 18, 2026 08:53
Comment thread popup/activators.js
Comment thread popup/activators.js
…ndMouseActivator

- Fix ClickActivator to show popup when allow_engines_without_selection is enabled
- Fix KeyAndMouseActivator popupShouldOpen to check _mouseButton instead of _options.button
@CFR0901 CFR0901 requested a review from Pitmairen March 24, 2026 15:07
@Pitmairen
Copy link
Copy Markdown
Owner

It seems to work fine now.

I'm merging it, but I will probably make a few tweaks before making a new release. I think I will disable it for the mouse click activator, because opening the popup on every click is probably not what most people wants.

But for the other activators, context menu and toolbar popup it works well.

@Pitmairen Pitmairen merged commit e1bddb8 into Pitmairen:master Apr 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants