Menu

#1697 Update global context search sample to use country restrictions

open
nobody
None
2026-06-02
2026-06-02
Anonymous
No

Originally created by: KirtiRamchandani

Fixes [#1653].

Problem
The global context search sample still described and implemented country-specific Google searches by switching Google domains. That no longer produces a useful visible difference for users, which makes the sample feel outdated even though it still demonstrates the contextMenus API.

Root cause
The sample stored top-level-domain IDs and built URLs such as https://google.ca/search. Modern Google Search localizes results independently of those domains.

Solution

  • Replace TLD options with country region codes.
  • Build searches against https://www.google.com/search with the cr=countryXX parameter.
  • Rename popup/storage variables to enabledRegions and update the README/manifest wording to match the new behavior.

Tests run

  • npx eslint api-samples/contextMenus/global_context_search/background.js api-samples/contextMenus/global_context_search/popup.js api-samples/contextMenus/global_context_search/locales.js
  • npx prettier --check api-samples/contextMenus/global_context_search/README.md api-samples/contextMenus/global_context_search/background.js api-samples/contextMenus/global_context_search/locales.js api-samples/contextMenus/global_context_search/manifest.json api-samples/contextMenus/global_context_search/popup.js
  • URL-construction smoke test over all region options
  • git diff --check origin/main..HEAD

Related

Tickets: #1653
Tickets: #1689

Discussion


Log in to post a comment.