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: + + + +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: + + + +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 @@ + + +
+ + +