Lean MV3 extension + standalone single-file ingest server that pulls watched sellers' full inventories from the Discogs API into discogs_full (mp_* schema), tracking price changes and sales over time. Successor to pliceclogs/marketwatcher; runs alongside the legacy plice server on a separate port (5057). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
42 lines
1.6 KiB
JavaScript
42 lines
1.6 KiB
JavaScript
/* discgod content script — adds a floating "Track in discgod" button on
|
|
* Discogs seller pages. Reads the username from the URL and asks the background
|
|
* worker to add it to the watchlist. Purely a convenience; all the real work
|
|
* happens in the background worker + server. */
|
|
|
|
(function () {
|
|
const m = location.pathname.match(/\/seller\/([^/?#]+)/);
|
|
if (!m) return;
|
|
const username = decodeURIComponent(m[1]);
|
|
if (document.getElementById("discgod-track-btn")) return;
|
|
|
|
const btn = document.createElement("button");
|
|
btn.id = "discgod-track-btn";
|
|
btn.textContent = "▶ Track in discgod";
|
|
Object.assign(btn.style, {
|
|
position: "fixed", right: "16px", bottom: "16px", zIndex: 99999,
|
|
padding: "9px 14px", borderRadius: "8px", border: "none",
|
|
background: "#4f9dff", color: "#07111f", fontWeight: "700",
|
|
fontSize: "13px", cursor: "pointer", fontFamily: "system-ui, sans-serif",
|
|
boxShadow: "0 3px 12px rgba(0,0,0,.35)",
|
|
});
|
|
|
|
btn.addEventListener("click", () => {
|
|
btn.disabled = true;
|
|
btn.textContent = "…";
|
|
chrome.runtime.sendMessage({ type: "track", body: { username, filter: {} } }, (r) => {
|
|
const ok = r && r.ok;
|
|
btn.textContent = ok ? `✓ Tracking ${username}` : "✕ Failed";
|
|
btn.style.background = ok ? "#38b000" : "#e5484d";
|
|
btn.style.color = "#fff";
|
|
setTimeout(() => {
|
|
btn.textContent = "▶ Track in discgod";
|
|
btn.style.background = "#4f9dff";
|
|
btn.style.color = "#07111f";
|
|
btn.disabled = false;
|
|
}, 2500);
|
|
});
|
|
});
|
|
|
|
document.body.appendChild(btn);
|
|
})();
|