Skip to content

Modernize contextMenus sample to use Google Search parameters instead…#1666

Open
Shreyans-704 wants to merge 2 commits intoGoogleChrome:mainfrom
Shreyans-704:fix-global-search-example
Open

Modernize contextMenus sample to use Google Search parameters instead…#1666
Shreyans-704 wants to merge 2 commits intoGoogleChrome:mainfrom
Shreyans-704:fix-global-search-example

Conversation

@Shreyans-704
Copy link
Copy Markdown

Closes #1653

Summary

Update the global_context_search sample to reflect modern Google Search behavior. The previous implementation relied on domain-based localization (e.g., google.ca, google.co.jp), which no longer affects search results.

Changes

  • Replace domain-based URLs with a single base: https://www.google.com/search
  • Add query parameters for region specificity:
    • cr (country restriction): e.g., countryCA, countryJP, countryRU
    • lr (language restriction): e.g., lang_en, lang_ja, lang_ru
  • Refactor locales.js into a structured regions configuration object
  • Improve code clarity and maintainability
  • Add inline documentation explaining modern search behavior
  • Update README to reflect current best practices

Why

Modern Google Search localizes results primarily based on IP geolocation, making domain-based localization ineffective. Using cr and lr parameters provides a more accurate and programmatic way to demonstrate regional search differences.

Testing

  • Loaded extension locally in Chrome
  • Verified context menu behavior
  • Confirmed region-specific search results differ as expected

@google-cla
Copy link
Copy Markdown

google-cla bot commented Apr 18, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

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.

"Global search" example seems outdated

1 participant