initial commit
This commit is contained in:
commit
95f5fdd3ea
19 files changed
+3050
No files matched your search
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* background.js — Service worker for the Goon Plugin extension.
|
||||
* Handles long-lived state, message routing, and lifecycle events.
|
||||
* Uses Manifest V3 module-type service worker.
|
||||
*/
|
||||
|
||||
// Fired when the extension is first installed / updated / Chrome starts.
|
||||
chrome.runtime.onInstalled.addListener((details) => {
|
||||
if (details.reason === 'install') {
|
||||
console.log('[goon-plugin] Extension installed');
|
||||
} else if (details.reason === 'update') {
|
||||
console.log(`[goon-plugin] Extension updated from ${details.previousVersion}`);
|
||||
}
|
||||
});
|
||||
|
||||
// Listen for messages from popup or content scripts.
|
||||
chrome.runtime.onMessage.addListener((message, _sender, sendResponse) => {
|
||||
console.log('[goon-plugin] Received:', message);
|
||||
|
||||
switch (message.type) {
|
||||
case 'PING':
|
||||
sendResponse({ pong: true, timestamp: Date.now() });
|
||||
break;
|
||||
|
||||
default:
|
||||
console.warn('[goon-plugin] Unknown message type:', message.type);
|
||||
sendResponse({ error: `Unknown type: ${message.type}` });
|
||||
break;
|
||||
}
|
||||
|
||||
return true; // keep sendResponse channel open for async work
|
||||
});
|
||||
@@ -0,0 +1,19 @@
|
||||
/**
|
||||
* content.js — Content script injected into matching pages.
|
||||
* Communicates with the background service worker via chrome.runtime.
|
||||
* Use cautiously: runs in the page's DOM context, so isolate from page globals.
|
||||
*/
|
||||
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
console.log('[goon-plugin] Content script loaded');
|
||||
|
||||
// Example: inject a small element into the page.
|
||||
// Uncomment and customize as needed.
|
||||
//
|
||||
// const badge = document.createElement('div');
|
||||
// badge.textContent = 'Goon Plugin Active';
|
||||
// badge.style.cssText = 'position:fixed;bottom:8px;right:8px;padding:4px 8px;...';
|
||||
// document.body.appendChild(badge);
|
||||
})();
|
||||
@@ -0,0 +1,15 @@
|
||||
# Icons
|
||||
|
||||
Place your extension icons here.
|
||||
|
||||
- `icon16.png` — 16x16 px, PNG
|
||||
- `icon48.png` — 48x48 px, PNG
|
||||
- `icon128.png` — 128x128 px, PNG
|
||||
|
||||
Tip: generate them from a single SVG source using [icon-generator](https://chrome.dev/tools/icon-generator/) or the `resvg` CLI:
|
||||
|
||||
```bash
|
||||
npx @resvg/resvg-js icon.svg -w 16 -h 16 -o icon16.png
|
||||
npx @resvg/resvg-js icon.svg -w 48 -h 48 -o icon48.png
|
||||
npx @resvg/resvg-js icon.svg -w 128 -h 128 -o icon128.png
|
||||
```
|
||||
@@ -0,0 +1,4 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 128">
|
||||
<rect width="128" height="128" rx="24" fill="#4361ee"/>
|
||||
<text x="64" y="84" text-anchor="middle" dominant-baseline="middle" font-size="64" font-weight="bold" font-family="sans-serif" fill="white">G</text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 279 B |
@@ -0,0 +1,53 @@
|
||||
:root {
|
||||
--bg: #ffffff;
|
||||
--text: #1a1a2e;
|
||||
--accent: #4361ee;
|
||||
--accent-hover: #3a56d4;
|
||||
--border: #e2e8f0;
|
||||
--radius: 8px;
|
||||
}
|
||||
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
||||
background: var(--bg);
|
||||
color: var(--text);
|
||||
min-width: 320px;
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
#app {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 18px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
#status {
|
||||
font-size: 14px;
|
||||
color: #64748b;
|
||||
}
|
||||
|
||||
button {
|
||||
padding: 8px 16px;
|
||||
background: var(--accent);
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: var(--radius);
|
||||
font-size: 14px;
|
||||
cursor: pointer;
|
||||
transition: background 150ms;
|
||||
}
|
||||
|
||||
button:hover {
|
||||
background: var(--accent-hover);
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Goon Plugin</title>
|
||||
<link rel="stylesheet" href="popup.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="app">
|
||||
<h1>Goon Plugin</h1>
|
||||
<p id="status">Ready</p>
|
||||
<button id="action-btn">Click me</button>
|
||||
</div>
|
||||
<script src="popup.js" type="module"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,19 @@
|
||||
/**
|
||||
* popup.js — UI logic for the extension popup.
|
||||
* Runs inside the popup iframe; uses chrome.runtime / chrome.storage APIs.
|
||||
*/
|
||||
|
||||
const actionBtn = document.getElementById('action-btn');
|
||||
const statusEl = document.getElementById('status');
|
||||
|
||||
actionBtn.addEventListener('click', async () => {
|
||||
// TODO: replace with actual extension logic
|
||||
try {
|
||||
const result = await chrome.storage.local.get(['counter']);
|
||||
const count = (result.counter ?? 0) + 1;
|
||||
await chrome.storage.local.set({ counter: count });
|
||||
statusEl.textContent = `Clicked ${count} time${count === 1 ? '' : 's'}`;
|
||||
} catch (err) {
|
||||
statusEl.textContent = `Error: ${err.message}`;
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user