opencode-browser-annotation-plugin 0.1.3 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,88 +0,0 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <style>
6
- body {
7
- font-family: system-ui, sans-serif;
8
- width: 320px;
9
- margin: 0;
10
- padding: 12px;
11
- color: #1a1a1a;
12
- }
13
- h1 {
14
- font-size: 14px;
15
- margin: 0 0 8px;
16
- }
17
- button {
18
- font: inherit;
19
- padding: 6px 10px;
20
- border: 1px solid #ccc;
21
- border-radius: 6px;
22
- background: #f7f7f7;
23
- cursor: pointer;
24
- }
25
- button.primary {
26
- background: #2b7cff;
27
- color: #fff;
28
- border-color: #2b7cff;
29
- }
30
- button:disabled {
31
- opacity: 0.5;
32
- cursor: default;
33
- }
34
- .row {
35
- display: flex;
36
- gap: 8px;
37
- margin-bottom: 8px;
38
- }
39
- #list {
40
- list-style: none;
41
- margin: 8px 0;
42
- padding: 0;
43
- max-height: 220px;
44
- overflow: auto;
45
- }
46
- #list li {
47
- border: 1px solid #eee;
48
- border-radius: 6px;
49
- padding: 6px 8px;
50
- margin-bottom: 6px;
51
- font-size: 12px;
52
- }
53
- #list .sel {
54
- color: #666;
55
- font-family: ui-monospace, monospace;
56
- word-break: break-all;
57
- }
58
- #list .rm {
59
- float: right;
60
- color: #c00;
61
- cursor: pointer;
62
- }
63
- #status {
64
- font-size: 12px;
65
- color: #666;
66
- min-height: 16px;
67
- }
68
- a {
69
- font-size: 11px;
70
- color: #2b7cff;
71
- }
72
- </style>
73
- </head>
74
- <body>
75
- <h1>OpenCode Browser Annotation</h1>
76
- <div class="row">
77
- <button id="pick" class="primary">Select element</button>
78
- <button id="clear">Clear</button>
79
- </div>
80
- <ul id="list"></ul>
81
- <div class="row">
82
- <button id="submit" class="primary">Submit to agent</button>
83
- </div>
84
- <div id="status"></div>
85
- <a href="#" id="opts">Settings</a>
86
- <script src="popup.js"></script>
87
- </body>
88
- </html>
@@ -1,71 +0,0 @@
1
- const listEl = document.getElementById("list");
2
- const statusEl = document.getElementById("status");
3
- const pickBtn = document.getElementById("pick");
4
- const clearBtn = document.getElementById("clear");
5
- const submitBtn = document.getElementById("submit");
6
-
7
- function send(msg) {
8
- return new Promise((resolve) => chrome.runtime.sendMessage(msg, resolve));
9
- }
10
-
11
- function setStatus(text) {
12
- statusEl.textContent = text || "";
13
- }
14
-
15
- async function render() {
16
- const res = await send({ type: "oc-list" });
17
- const annotations = res?.annotations || [];
18
- listEl.innerHTML = "";
19
- submitBtn.disabled = annotations.length === 0;
20
- for (let i = 0; i < annotations.length; i++) {
21
- const a = annotations[i];
22
- const li = document.createElement("li");
23
- const instruction = (a.instruction || "(no instruction)").replace(/</g, "&lt;");
24
- const sel = (a.element?.selector || a.element?.tag || "").replace(/</g, "&lt;");
25
- li.innerHTML = `<span class="rm" data-i="${i}">✕</span><div>${instruction}</div><div class="sel">${sel}</div>`;
26
- listEl.appendChild(li);
27
- }
28
- listEl.querySelectorAll(".rm").forEach((el) => {
29
- el.addEventListener("click", async () => {
30
- await send({ type: "oc-remove", index: Number(el.dataset.i) });
31
- render();
32
- });
33
- });
34
- }
35
-
36
- pickBtn.addEventListener("click", async () => {
37
- const [tab] = await chrome.tabs.query({ active: true, currentWindow: true });
38
- if (!tab?.id) return;
39
- try {
40
- await chrome.scripting.executeScript({ target: { tabId: tab.id }, files: ["content.js"] });
41
- setStatus("Hover an element and click it. Esc to cancel.");
42
- window.close();
43
- } catch (error) {
44
- setStatus("Cannot inject here (e.g. chrome:// pages).");
45
- }
46
- });
47
-
48
- clearBtn.addEventListener("click", async () => {
49
- await send({ type: "oc-clear" });
50
- render();
51
- });
52
-
53
- submitBtn.addEventListener("click", async () => {
54
- submitBtn.disabled = true;
55
- setStatus("Submitting…");
56
- const res = await send({ type: "oc-submit" });
57
- if (res?.ok) {
58
- setStatus(`Sent ${res.count} annotation(s) to the agent.`);
59
- render();
60
- } else {
61
- setStatus(`Failed: ${res?.error || "unknown error"}`);
62
- submitBtn.disabled = false;
63
- }
64
- });
65
-
66
- document.getElementById("opts").addEventListener("click", (e) => {
67
- e.preventDefault();
68
- chrome.runtime.openOptionsPage();
69
- });
70
-
71
- render();