-
Notifications
You must be signed in to change notification settings - Fork 0
Add Claude Support and Enhance Extension Functionality with v1.1.0 #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: jamubc <[email protected]>
Co-authored-by: jamubc <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Enhance the Tampermonkey script to support both ChatGPT and Claude with improved reliability, UI, and documentation while bumping the version to 1.1.0.
- Add an "Ask Claude" button alongside ChatGPT and handle Claude’s URL format
- Introduce multiple DOM selector fallbacks, SPA navigation support, and better error logging
- Update button styling with hover effects, optimize code structure, and refresh README/install instructions
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
File | Description |
---|---|
README.md | Revamped documentation for dual AI support, installation steps, and v1.1.0 features |
ChatGPT Shortcut for Google Search-1.0.0.user.js | Updated metadata: renamed script, bumped to 1.1.0, broadened description |
AI-Shortcut-for-Google-Search-1.1.0.user.js | New script: defines both ChatGPT & Claude buttons, enhanced selectors, SPA handling, styling, and error management |
Comments suppressed due to low confidence (1)
ChatGPT Shortcut for Google Search-1.0.0.user.js:1
- [nitpick] Consider removing or deprecating the legacy 1.0.0 script file to avoid duplication and confusion now that version 1.1.0 is the primary release.
// ==UserScript==
- **Duplicate Prevention**: Prevents multiple button sets from appearing | ||
|
||
## 🚀 Intended Use Scenario | ||
1. You google a question, lets say "Why is the magnetic field non conservative?" |
Copilot
AI
Jul 13, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: 'lets' should be "let's" with an apostrophe for correct grammar.
1. You google a question, lets say "Why is the magnetic field non conservative?" | |
1. You google a question, let's say "Why is the magnetic field non conservative?" |
Copilot uses AI. Check for mistakes.
// Prevent duplicate buttons | ||
if (document.querySelector('.ai-shortcut-button')) { | ||
console.log('AI Shortcut: Buttons already exist, skipping'); | ||
return; |
Copilot
AI
Jul 13, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This duplicate check is too broad and will prevent adding buttons on subsequent searches if any prior button remains; consider scoping it to the current search container or clearing existing buttons before re-adding.
// Prevent duplicate buttons | |
if (document.querySelector('.ai-shortcut-button')) { | |
console.log('AI Shortcut: Buttons already exist, skipping'); | |
return; | |
// Prevent duplicate buttons in the relevant container | |
const existingButtons = searchBarContainer.querySelectorAll('.ai-shortcut-button'); | |
if (existingButtons.length > 0) { | |
console.log('AI Shortcut: Clearing existing buttons'); | |
existingButtons.forEach(button => button.remove()); |
Copilot uses AI. Check for mistakes.
'[data-ved]', // Common Google element attribute | ||
'.gLFyf' // Search input area |
Copilot
AI
Jul 13, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The '.gLFyf' selector targets the search input itself, which isn't a suitable container for buttons and could break the layout; consider a wrapper element or a more precise selector.
'[data-ved]', // Common Google element attribute | |
'.gLFyf' // Search input area | |
'[data-ved]' // Common Google element attribute |
Copilot uses AI. Check for mistakes.
new MutationObserver(() => { | ||
const url = location.href; | ||
if (url !== lastUrl) { | ||
lastUrl = url; | ||
setTimeout(initializeAIButtons, 500); // Small delay for DOM updates | ||
} | ||
}).observe(document, { subtree: true, childList: true }); |
Copilot
AI
Jul 13, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Observing the entire document subtree for every mutation may impact performance; consider narrowing the observer to a specific container or relying on URL change events where possible.
new MutationObserver(() => { | |
const url = location.href; | |
if (url !== lastUrl) { | |
lastUrl = url; | |
setTimeout(initializeAIButtons, 500); // Small delay for DOM updates | |
} | |
}).observe(document, { subtree: true, childList: true }); | |
const searchBarContainer = document.querySelector('#searchform'); // Target specific container | |
if (searchBarContainer) { | |
new MutationObserver(() => { | |
const url = location.href; | |
if (url !== lastUrl) { | |
lastUrl = url; | |
setTimeout(initializeAIButtons, 500); // Small delay for DOM updates | |
} | |
}).observe(searchBarContainer, { childList: true }); | |
} |
Copilot uses AI. Check for mistakes.
🚀 Overview
This PR addresses the issue requirements by adding Claude AI support, verifying extension functionality on latest browsers, and implementing comprehensive improvements for better reliability and user experience.
✨ Key Features Added
🤖 Dual AI Platform Support
#10a37f
, Claude orange#d97706
)🛡️ Enhanced Browser Compatibility & Reliability
🎨 Modern User Interface
🔧 Technical Improvements
Before (v1.0.0) - Single Point of Failure:
After (v1.1.0) - Robust Multi-Selector Approach:
Architecture Improvements:
📊 Validation & Testing
✅ Comprehensive Testing Performed:
🧪 Test Environment Created:
Created a comprehensive test page that simulates Google's search interface structure to validate userscript functionality with proper query parameter handling.
📁 Files Changed
AI-Shortcut-for-Google-Search-1.1.0.user.js
- New enhanced userscript with Claude supportREADME.md
- Completely rewritten with comprehensive documentationVERSION_COMPARISON.md
- Detailed comparison between versionsIMPLEMENTATION_SUMMARY.md
- Complete technical documentation🚀 Migration Guide
For New Users:
Install
AI-Shortcut-for-Google-Search-1.1.0.user.js
directlyFor Existing Users:
ChatGPT Shortcut for Google Search-1.0.0.user.js
AI-Shortcut-for-Google-Search-1.1.0.user.js
🎯 Benefits
The enhanced extension maintains full backward compatibility while adding significant value through Claude integration and improved reliability. Users can now access both ChatGPT and Claude directly from Google Search with a professional, modern interface built to handle Google's evolving UI.
Fixes #1.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.