feat(google-scholar): add cite and profile commands, fix search dedup#1176
feat(google-scholar): add cite and profile commands, fix search dedup#1176Benjamin-eecs wants to merge 1 commit intojackwener:mainfrom
Conversation
02db0de to
9cc37a4
Compare
There was a problem hiding this comment.
Pull request overview
Adds new cite and profile commands to the google-scholar adapter and fixes duplicate search results caused by an overly-broad CSS selector.
Changes:
- Fix
searchresult deduplication by narrowing the result container selector. - Add
google-scholar citeto fetch formatted citations (BibTeX/EndNote/RefMan/RefWorks) from Scholar. - Add
google-scholar profileto fetch author profile metrics and top papers (by name lookup or direct user ID).
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| clis/google-scholar/search.js | Narrows the DOM selector to avoid double-counting results. |
| clis/google-scholar/cite.js | Introduces a new command to open the cite dialog and fetch formatted citation content. |
| clis/google-scholar/profile.js | Introduces a new command to navigate to an author profile and extract stats + papers. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| cli({ | ||
| site: 'google-scholar', | ||
| name: 'profile', | ||
| description: 'View a Google Scholar author profile', | ||
| domain: 'scholar.google.com', | ||
| strategy: Strategy.PUBLIC, | ||
| browser: true, | ||
| args: [ | ||
| { name: 'author', positional: true, required: true, help: 'Author name or Scholar user ID (e.g. JicYPdAAAAAJ)' }, | ||
| { name: 'limit', type: 'int', default: 10, help: 'Max papers to show (max 20)' }, | ||
| ], | ||
| columns: ['rank', 'title', 'cited', 'year'], | ||
| navigateBefore: false, | ||
| func: async (page, kwargs) => { | ||
| const author = requireNonEmptyQuery(kwargs.author, 'author'); | ||
| const limit = clampInt(kwargs.limit, 10, 1, 20); |
There was a problem hiding this comment.
Missing tests for the new google-scholar/profile command. Since this adapter already has vitest coverage for command registration and pre-navigation argument validation (clis/google-scholar/search.test.js), add a profile.test.js to verify the command is registered correctly and that empty/whitespace author input is rejected before calling page.goto.
| cli({ | ||
| site: 'google-scholar', | ||
| name: 'cite', | ||
| description: 'Get citation (BibTeX) for a Google Scholar paper', |
There was a problem hiding this comment.
The command description says it gets citation “(BibTeX)”, but the command supports multiple formats via --style (endnote/refman/refworks). Update the description to reflect all supported formats so opencli ... --help is accurate.
| description: 'Get citation (BibTeX) for a Google Scholar paper', | |
| description: 'Get citation for a Google Scholar paper', |
| cli({ | ||
| site: 'google-scholar', | ||
| name: 'cite', | ||
| description: 'Get citation (BibTeX) for a Google Scholar paper', | ||
| domain: 'scholar.google.com', | ||
| strategy: Strategy.PUBLIC, | ||
| browser: true, | ||
| args: [ | ||
| { name: 'query', positional: true, required: true, help: 'Paper title to search for' }, | ||
| { name: 'style', default: 'bibtex', choices: ['bibtex', 'endnote', 'refman', 'refworks'], help: 'Citation format' }, | ||
| { name: 'index', type: 'int', default: 1, help: 'Which search result to cite (1-based)' }, | ||
| ], | ||
| columns: ['title', 'format', 'citation'], | ||
| navigateBefore: false, | ||
| func: async (page, kwargs) => { |
There was a problem hiding this comment.
Missing tests for the new google-scholar/cite command. This repo already uses vitest for CLI command registration/argument validation (e.g., clis/google-scholar/search.test.js); please add a similar test file to cover command registration and that empty/whitespace queries are rejected before any browser navigation.
7b8cb3a to
c493d49
Compare
- cite: get BibTeX/EndNote/RefMan/RefWorks citation for a paper. Clicks the cite button in search results and fetches the citation content from Google's citation endpoint. - profile: view an author's Google Scholar profile (h-index, i10-index, citation count, top papers). Accepts author name or Scholar user ID. - search: fix duplicate results caused by CSS selector matching both outer container (.gs_r.gs_or.gs_scl) and inner child (.gs_ri) for each paper. Closes jackwener#1174, closes jackwener#1175
c493d49 to
f087019
Compare
Description
Three changes to the google-scholar adapter:
Fix search duplicate results ([Bug]: google-scholar search returns duplicate results #1174). The CSS selector
.gs_r.gs_or.gs_scl, .gs_rimatched both the outer container and its inner.gs_richild, producing every paper twice. Changed to.gs_r.gs_or.gs_sclonly.Add
citecommand ([Feature]: add cite and profile commands to google-scholar adapter #1175). Get BibTeX/EndNote/RefMan/RefWorks citation for a paper. Searches for the paper, clicks the cite button in search results, and navigates to Google's citation endpoint to fetch the formatted content. Supports--styleto choose format and--indexto pick which result to cite.Add
profilecommand ([Feature]: add cite and profile commands to google-scholar adapter #1175). View an author's Google Scholar profile: name, affiliation, h-index, i10-index, total citations, and top papers. Accepts either an author name (searches for the profile) or a 12-char Scholar user ID (navigates directly).Fixes #1174, closes #1175
Type of Change
Checklist
Documentation (if adding/modifying an adapter)
docs/adapters/(if new adapter)docs/adapters/index.mdtable (if new adapter)docs/.vitepress/config.mts(if new adapter)README.md/README.zh-CN.mdwhen command discoverability changedCliErrorsubclasses instead of rawErrorScreenshots / Output
search (dedup fix):
cite:
profile: