Open
Conversation
…h out changing pages Introduce an inline settings panel in the popup with a toggle button and controls for popup modifier, max results and TTS rate. Added UI (popup.html) and styles (main.css) for the panel, wired load/save logic and visual feedback in popup.js (persisting to chrome.storage.sync), and updated options defaults (options.js). content.js now reads and responds to maxResults from storage (updates MAX_RESULTS and listens for changes) and popup TTS uses the stored ttsRate. Includes UX tweaks like a close button, status message and link to full settings.
… worker to avoid CORS dependency on host page origin fix: resolve "Failed to fetch results" by using regex HTML parser in service worker (no DOMParser in MV3 workers), fix duplicate context menu error by creating menu items in onInstalled listener feat: cache popup panel DOM element for reuse instead of recreating on every double-click (cherry picked from commit f2c56cb)
Contributor
Author
There was a problem hiding this comment.
Pull request overview
This PR updates the Tureng Chrome extension’s MV3 architecture by moving Tureng lookups into the background service worker (to avoid page-origin CORS/DOMParser constraints), adds an inline settings panel in the popup UI, and improves the in-page translation popup behavior by caching its DOM panel for reuse.
Changes:
- Add an inline settings panel in the extension popup (modifier key, max results, TTS rate) and persist these via
chrome.storage.sync. - Refactor the content-script selection popup to reuse a cached panel element and request translations through the background worker.
- Implement a regex-based HTML parser in the background worker and adjust context menu creation to run in
onInstalled.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| Tureng/styles/main.css | Adds styling for the new inline settings toggle button and panel in the popup. |
| Tureng/scripts/popup.js | Implements settings panel logic + persisted TTS rate usage in popup TTS actions. |
| Tureng/scripts/options.js | Extends defaults to include new settings keys (but options UI/save logic remains modifier-only). |
| Tureng/scripts/content.js | Caches and reuses the selection popup panel; fetches results via background messaging; syncs maxResults. |
| Tureng/scripts/background.js | Creates context menu on install; adds Tureng fetch + regex parsing endpoint for the content script. |
| Tureng/popup.html | Adds the inline settings panel markup and settings toggle/close controls. |
Comments suppressed due to low confidence (1)
Tureng/scripts/options.js:33
defaultSettingsnow includesmaxResultsandttsRate, but this options page still only applies/savesmodifier. Either remove the unused defaults here, or extend the options UI + save logic to manage the new settings as well so the settings surface is consistent.
const defaultSettings = {
modifier: 'alt',
maxResults: 5,
ttsRate: 0.8
};
const modifierSelect = document.getElementById('modifier-select');
const statusEl = document.getElementById('options-status');
function showSaved() {
if (!statusEl) {
return;
}
statusEl.style.display = 'block';
clearTimeout(showSaved._timer);
showSaved._timer = setTimeout(() => {
statusEl.style.display = 'none';
}, 1200);
}
function applySettings(settings) {
if (modifierSelect) {
modifierSelect.value = settings.modifier;
}
}
function saveSettings() {
const modifier = modifierSelect ? modifierSelect.value : defaultSettings.modifier;
chrome.storage.sync.set({ modifier }, showSaved);
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- render selection popup content with DOM APIs instead of innerHTML - encode selected text before building Tureng URLs - fix Turkish labels in popup settings - decode html entities from parsed background results
Contributor
Author
|
@kdemirel revised |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
refactor: move Tureng fetch from content script to background service worker to avoid CORS dependency on host page origin
fix: resolve "Failed to fetch results" by using regex HTML parser in service worker (no DOMParser in MV3 workers), fix duplicate context menu error by creating menu items in onInstalled listener
feat: cache popup panel DOM element for reuse instead of recreating on every double-click