Pokemon Stock Monitor - Initial commit
Chrome extension for PokemonCenter monitoring with Discord notifications. Includes Python scripts for Target monitoring. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
// Pokemon Stock Monitor - Popup Script
|
||||
|
||||
document.addEventListener("DOMContentLoaded", async () => {
|
||||
// Load current config
|
||||
const config = await chrome.runtime.sendMessage({ type: "getConfig" });
|
||||
const stats = await chrome.runtime.sendMessage({ type: "getStats" });
|
||||
|
||||
// Populate form
|
||||
document.getElementById("webhook").value = config.discordWebhook || "";
|
||||
document.getElementById("urls").value = (config.urls || []).join("\n");
|
||||
document.getElementById("keywords").value = (config.keywords || []).join(", ");
|
||||
document.getElementById("interval").value = config.checkIntervalMinutes || 1;
|
||||
document.getElementById("enabled").checked = config.enabled !== false;
|
||||
document.getElementById("notifyNew").checked = config.notifyNewProducts !== false;
|
||||
document.getElementById("notifyRestock").checked = config.notifyRestocks !== false;
|
||||
|
||||
// Update stats
|
||||
document.getElementById("productCount").textContent = stats.totalProducts || 0;
|
||||
updateStatus(stats.enabled !== false);
|
||||
|
||||
// Save button
|
||||
document.getElementById("saveBtn").addEventListener("click", async () => {
|
||||
const urlsText = document.getElementById("urls").value;
|
||||
const keywordsText = document.getElementById("keywords").value;
|
||||
|
||||
const newConfig = {
|
||||
discordWebhook: document.getElementById("webhook").value.trim(),
|
||||
urls: urlsText.split("\n").map(u => u.trim()).filter(u => u),
|
||||
keywords: keywordsText.split(",").map(k => k.trim()).filter(k => k),
|
||||
checkIntervalMinutes: parseInt(document.getElementById("interval").value) || 1,
|
||||
enabled: document.getElementById("enabled").checked,
|
||||
notifyNewProducts: document.getElementById("notifyNew").checked,
|
||||
notifyRestocks: document.getElementById("notifyRestock").checked
|
||||
};
|
||||
|
||||
await chrome.runtime.sendMessage({ type: "saveConfig", config: newConfig });
|
||||
updateStatus(newConfig.enabled);
|
||||
showSaved();
|
||||
});
|
||||
|
||||
// Check Now button
|
||||
document.getElementById("checkNowBtn").addEventListener("click", async () => {
|
||||
await chrome.runtime.sendMessage({ type: "runCheck" });
|
||||
showSaved("Check started!");
|
||||
});
|
||||
|
||||
// Clear button
|
||||
document.getElementById("clearBtn").addEventListener("click", async () => {
|
||||
if (confirm("Clear all tracked products? This will treat all products as new on next check.")) {
|
||||
await chrome.runtime.sendMessage({ type: "clearProducts" });
|
||||
document.getElementById("productCount").textContent = "0";
|
||||
showSaved("History cleared!");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function updateStatus(enabled) {
|
||||
const dot = document.getElementById("statusDot");
|
||||
const text = document.getElementById("statusText");
|
||||
|
||||
if (enabled) {
|
||||
dot.className = "status-dot active";
|
||||
text.textContent = "Active";
|
||||
} else {
|
||||
dot.className = "status-dot inactive";
|
||||
text.textContent = "Disabled";
|
||||
}
|
||||
}
|
||||
|
||||
function showSaved(msg = "Settings saved!") {
|
||||
const el = document.getElementById("savedMsg");
|
||||
el.textContent = msg;
|
||||
el.classList.add("show");
|
||||
setTimeout(() => el.classList.remove("show"), 2000);
|
||||
}
|
||||
Reference in New Issue
Block a user