diff --git a/opera-extension/README.md b/opera-extension/README.md new file mode 100644 index 0000000000..abe3feab9a --- /dev/null +++ b/opera-extension/README.md @@ -0,0 +1,24 @@ +# Google Search (Opera) — Extension + +This small Opera extension adds: + +- a context menu item when text is selected: "Search Google for \"%s\"" +- a popup to type a query or open Google quickly + +Screenshots: + +![Popup screenshot](screenshots/popup.svg) + +How to load in Opera: + +1. Open Opera and navigate to `opera://extensions`. +2. Enable Developer mode (toggle in the top-right). +3. Click **Load unpacked** and select this folder: the `opera-extension` directory. + +Icon preview: + +![Icon preview](icons/icon128.png) + +Notes: + +- This is a Chromium-style extension and should be compatible with Opera's extension system. diff --git a/opera-extension/background.js b/opera-extension/background.js new file mode 100644 index 0000000000..5f9cd9197e --- /dev/null +++ b/opera-extension/background.js @@ -0,0 +1,15 @@ +chrome.runtime.onInstalled.addListener(() => { + chrome.contextMenus.create({ + id: 'search-google', + title: 'Search Google for "%s"', + contexts: ['selection'] + }); +}); + +chrome.contextMenus.onClicked.addListener((info, tab) => { + if (info.menuItemId === 'search-google') { + const query = info.selectionText || ''; + const url = 'https://www.google.com/search?q=' + encodeURIComponent(query); + chrome.tabs.create({ url }); + } +}); diff --git a/opera-extension/icons/icon128.png b/opera-extension/icons/icon128.png new file mode 100644 index 0000000000..88df5a5a62 Binary files /dev/null and b/opera-extension/icons/icon128.png differ diff --git a/opera-extension/icons/icon128.svg b/opera-extension/icons/icon128.svg new file mode 100644 index 0000000000..edd15a4f39 --- /dev/null +++ b/opera-extension/icons/icon128.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/opera-extension/icons/icon48.png b/opera-extension/icons/icon48.png new file mode 100644 index 0000000000..2ccc57586f Binary files /dev/null and b/opera-extension/icons/icon48.png differ diff --git a/opera-extension/icons/icon48.svg b/opera-extension/icons/icon48.svg new file mode 100644 index 0000000000..a7490c6588 --- /dev/null +++ b/opera-extension/icons/icon48.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/opera-extension/manifest.json b/opera-extension/manifest.json new file mode 100644 index 0000000000..de0c2eaaeb --- /dev/null +++ b/opera-extension/manifest.json @@ -0,0 +1,21 @@ +{ + "manifest_version": 3, + "name": "Google Search (Opera)", + "description": "Adds a context-menu and popup to quickly search selected text on Google.", + "version": "1.0.0", + "permissions": ["contextMenus", "tabs"], + "background": { + "service_worker": "background.js" + }, + "action": { + "default_popup": "popup.html", + "default_icon": { + "48": "icons/icon48.png", + "128": "icons/icon128.png" + } + }, + "icons": { + "48": "icons/icon48.png", + "128": "icons/icon128.png" + } +} diff --git a/opera-extension/popup.html b/opera-extension/popup.html new file mode 100644 index 0000000000..641abc90d0 --- /dev/null +++ b/opera-extension/popup.html @@ -0,0 +1,19 @@ + + + + + + Google Search + + + +
+ +
+ + +
+
+ + + diff --git a/opera-extension/popup.js b/opera-extension/popup.js new file mode 100644 index 0000000000..221aab2627 --- /dev/null +++ b/opera-extension/popup.js @@ -0,0 +1,10 @@ +document.getElementById('search').addEventListener('click', () => { + const q = document.getElementById('q').value.trim(); + if (!q) return; + const url = 'https://www.google.com/search?q=' + encodeURIComponent(q); + chrome.tabs.create({ url }); +}); + +document.getElementById('open').addEventListener('click', () => { + chrome.tabs.create({ url: 'https://www.google.com/' }); +}); diff --git a/opera-extension/screenshots/popup.svg b/opera-extension/screenshots/popup.svg new file mode 100644 index 0000000000..dc8ccaff0e --- /dev/null +++ b/opera-extension/screenshots/popup.svg @@ -0,0 +1,11 @@ + + + + Search Google... + + example query + + Search + + Open Google + diff --git a/opera-extension/styles.css b/opera-extension/styles.css new file mode 100644 index 0000000000..6ed8d214ee --- /dev/null +++ b/opera-extension/styles.css @@ -0,0 +1,6 @@ +body{font-family: system-ui, Arial, sans-serif; margin:0; padding:8px; width:260px} +.container{display:flex;flex-direction:column;gap:8px} +input#q{padding:8px;border:1px solid #ccc;border-radius:4px;width:100%} +.buttons{display:flex;gap:8px} +button{flex:1;padding:8px;border:none;border-radius:4px;background:#1a73e8;color:#fff;cursor:pointer} +button#open{background:#5f6368}