How It Works
Text Selection
Select any text on a webpage (minimum 2 characters). The Knowledge button appears above your selection.
Fetch Wikipedia Data
When clicked, the extension sends a request to Wikipedia’s REST API using the search term.
Fallback Search
If no exact match is found (404 error), the extension uses Wikipedia’s OpenSearch API to find the closest matching article.
API Endpoint Used
The Summary tab uses Wikipedia’s REST API v1:The extension automatically detects language: it uses
ar.wikipedia.org for Arabic text and en.wikipedia.org for English.Code Implementation
Fromcontent.js, the main fetch logic:
content.js:393-465 for the complete implementation.
What Users See
The Summary tab displays:- Thumbnail Image - If the Wikipedia article has a lead image
- Article Title - The official Wikipedia article title
- Extract Text - A 2-3 sentence summary (provided by Wikipedia)
- Read More Link - Opens the full Wikipedia article in a new tab
The extension caches up to 30 results per session to minimize API calls and improve performance.
Language Support
The Summary tab fully supports both English and Arabic:- Automatic detection: Uses Arabic regex pattern to detect Arabic text
- Manual override: Users can set a preferred language in extension settings
- RTL support: Tooltip automatically applies right-to-left layout for Arabic
Error Handling
The Summary tab handles several error cases:404 - Article Not Found
404 - Article Not Found
When Wikipedia returns a 404 error, the extension automatically performs a search query to find similar articles. If a match is found, it fetches that article instead. If no match exists, displays: “No Wikipedia article found for [term].”
429 - Rate Limited
429 - Rate Limited
Displays: “Too many requests. Please try again in a moment.” This occurs when the user makes too many requests in a short time.
Network Errors
Network Errors
Displays: “Unable to connect. Please check your internet connection.” when the request fails due to connectivity issues.
Data Source
Wikipedia REST API: Free, no authentication required- English: https://en.wikipedia.org/api/rest_v1/
- Arabic: https://ar.wikipedia.org/api/rest_v1/
- Documentation: https://www.mediawiki.org/wiki/API:REST_API