Skip to content
Closed

[spam] #3217

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions opera-extension/README.md
Original file line number Diff line number Diff line change
@@ -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.
15 changes: 15 additions & 0 deletions opera-extension/background.js
Original file line number Diff line number Diff line change
@@ -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 });
}
});
Binary file added opera-extension/icons/icon128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions opera-extension/icons/icon128.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added opera-extension/icons/icon48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions opera-extension/icons/icon48.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions opera-extension/manifest.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
19 changes: 19 additions & 0 deletions opera-extension/popup.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Google Search</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div class="container">
<input id="q" placeholder="Search Google..." autofocus />
<div class="buttons">
<button id="search">Search</button>
<button id="open">Open Google</button>
</div>
</div>
<script src="popup.js"></script>
</body>
</html>
10 changes: 10 additions & 0 deletions opera-extension/popup.js
Original file line number Diff line number Diff line change
@@ -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/' });
});
11 changes: 11 additions & 0 deletions opera-extension/screenshots/popup.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions opera-extension/styles.css
Original file line number Diff line number Diff line change
@@ -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}
Loading