Initial Commit
This commit is contained in:
+295
@@ -0,0 +1,295 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Discord Presence</title>
|
||||
<script src="https://cdn.tailwindcss.com"></script>
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet" />
|
||||
<script>
|
||||
tailwind.config = {
|
||||
theme: {
|
||||
extend: {
|
||||
fontFamily: { sans: ['Inter', 'system-ui', 'sans-serif'] },
|
||||
colors: {
|
||||
surface: { 900: '#0c0e14', 800: '#13161e', 700: '#1a1e2a', 600: '#242938' },
|
||||
accent: { DEFAULT: '#7c6fef', light: '#9b8ff5', dim: '#5a4fcf' },
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
body { background: #0c0e14; }
|
||||
input:focus { outline: none; }
|
||||
.status-dot { width: 8px; height: 8px; border-radius: 50%; }
|
||||
.status-dot.on { background: #34d399; box-shadow: 0 0 6px #34d39966; }
|
||||
.status-dot.off { background: #64748b; }
|
||||
.btn-primary {
|
||||
background: linear-gradient(135deg, #7c6fef, #5a4fcf);
|
||||
transition: all 0.15s ease;
|
||||
}
|
||||
.btn-primary:hover { filter: brightness(1.15); transform: translateY(-1px); }
|
||||
.btn-primary:active { transform: translateY(0); }
|
||||
.btn-primary:disabled { opacity: 0.4; pointer-events: none; }
|
||||
.input-field {
|
||||
background: #1a1e2a;
|
||||
border: 1px solid #242938;
|
||||
transition: border-color 0.15s ease;
|
||||
}
|
||||
.input-field:focus { border-color: #7c6fef; }
|
||||
.preview-card {
|
||||
background: #13161e;
|
||||
border-left: 3px solid #7c6fef;
|
||||
}
|
||||
.toast {
|
||||
animation: toast-in 0.25s ease, toast-out 0.3s ease 2.2s forwards;
|
||||
}
|
||||
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
|
||||
@keyframes toast-out { to { opacity: 0; transform: translateY(-4px); } }
|
||||
|
||||
/* Help modal */
|
||||
.modal-backdrop {
|
||||
background: rgba(0, 0, 0, 0.7);
|
||||
backdrop-filter: blur(4px);
|
||||
animation: fade-in 0.15s ease;
|
||||
}
|
||||
.modal-content {
|
||||
animation: slide-up 0.2s ease;
|
||||
}
|
||||
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
|
||||
@keyframes slide-up { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
|
||||
|
||||
.step-number {
|
||||
width: 22px; height: 22px;
|
||||
background: linear-gradient(135deg, #7c6fef, #5a4fcf);
|
||||
border-radius: 50%;
|
||||
display: flex; align-items: center; justify-content: center;
|
||||
font-size: 11px; font-weight: 700;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
/* Hide number spinners */
|
||||
input[type=number]::-webkit-inner-spin-button,
|
||||
input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
|
||||
input[type=number] { -moz-appearance: textfield; }
|
||||
</style>
|
||||
</head>
|
||||
<body class="font-sans text-slate-200 select-none overflow-hidden h-screen flex flex-col">
|
||||
|
||||
<!-- Header -->
|
||||
<header class="flex items-center gap-3 px-5 pt-5 pb-3">
|
||||
<div class="w-8 h-8 rounded-lg bg-accent/20 flex items-center justify-center">
|
||||
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="#7c6fef" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
|
||||
<circle cx="12" cy="12" r="10"/><polygon points="10 8 16 12 10 16 10 8"/>
|
||||
</svg>
|
||||
</div>
|
||||
<h1 class="text-base font-semibold tracking-tight">Discord Presence</h1>
|
||||
<div class="flex-1"></div>
|
||||
<button onclick="openHelp()"
|
||||
class="w-7 h-7 rounded-lg bg-surface-700 hover:bg-surface-600 flex items-center justify-center text-slate-400 hover:text-slate-200 transition-colors text-xs font-bold"
|
||||
title="Setup guide">?</button>
|
||||
<div class="flex items-center gap-2 ml-1">
|
||||
<div id="statusDot" class="status-dot off"></div>
|
||||
<span id="statusLabel" class="text-xs text-slate-500">Disconnected</span>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<main class="flex-1 overflow-y-auto px-5 pb-5 space-y-4">
|
||||
|
||||
<!-- Connection -->
|
||||
<section class="bg-surface-800 rounded-xl p-4 space-y-3">
|
||||
<label class="block text-xs font-medium text-slate-400 uppercase tracking-wider">Application ID</label>
|
||||
<div class="flex gap-2">
|
||||
<input
|
||||
id="appId"
|
||||
type="text"
|
||||
placeholder="Paste your Discord Application ID"
|
||||
class="input-field flex-1 rounded-lg px-3 py-2 text-sm text-slate-200 placeholder-slate-600"
|
||||
/>
|
||||
<button id="connectBtn" onclick="toggleConnection()"
|
||||
class="btn-primary text-white text-sm font-medium px-4 py-2 rounded-lg">
|
||||
Connect
|
||||
</button>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- Activity -->
|
||||
<section class="bg-surface-800 rounded-xl p-4 space-y-3">
|
||||
<label class="block text-xs font-medium text-slate-400 uppercase tracking-wider">Activity</label>
|
||||
|
||||
<div>
|
||||
<label class="block text-xs text-slate-500 mb-1">Status</label>
|
||||
<input
|
||||
id="statusInput"
|
||||
type="text"
|
||||
placeholder="Whatever you want"
|
||||
maxlength="128"
|
||||
class="input-field w-full rounded-lg px-3 py-2 text-sm text-slate-200 placeholder-slate-600"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block text-xs text-slate-500 mb-1">Details</label>
|
||||
<input
|
||||
id="detailsInput"
|
||||
type="text"
|
||||
placeholder="Optional second line"
|
||||
maxlength="128"
|
||||
class="input-field w-full rounded-lg px-3 py-2 text-sm text-slate-200 placeholder-slate-600"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center justify-between pt-1">
|
||||
<label class="flex items-center gap-2 cursor-pointer">
|
||||
<input id="showTime" type="checkbox" checked
|
||||
class="w-4 h-4 rounded bg-surface-700 border-surface-600 text-accent focus:ring-accent/40 cursor-pointer" />
|
||||
<span class="text-sm text-slate-400">Show elapsed time</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div id="timeInputs" class="flex gap-2 pt-1">
|
||||
<div class="flex-1">
|
||||
<label class="block text-xs text-slate-500 mb-1">Hours</label>
|
||||
<input id="elapsedHours" type="number" min="0" value="0" placeholder="0"
|
||||
class="input-field w-full rounded-lg px-3 py-2 text-sm text-slate-200 placeholder-slate-600" />
|
||||
</div>
|
||||
<div class="flex-1">
|
||||
<label class="block text-xs text-slate-500 mb-1">Minutes</label>
|
||||
<input id="elapsedMins" type="number" min="0" max="59" value="0" placeholder="0"
|
||||
class="input-field w-full rounded-lg px-3 py-2 text-sm text-slate-200 placeholder-slate-600" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex gap-2 pt-1">
|
||||
<button onclick="setActivity()" id="setBtn" disabled
|
||||
class="btn-primary flex-1 text-white text-sm font-medium px-4 py-2 rounded-lg">
|
||||
Set Status
|
||||
</button>
|
||||
<button onclick="clearActivity()" id="clearBtn" disabled
|
||||
class="flex-1 text-sm font-medium px-4 py-2 rounded-lg bg-surface-700 text-slate-400 hover:bg-surface-600 hover:text-slate-200 transition-colors disabled:opacity-30 disabled:pointer-events-none">
|
||||
Clear
|
||||
</button>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- Live Preview -->
|
||||
<section class="bg-surface-800 rounded-xl p-4 space-y-2">
|
||||
<label class="block text-xs font-medium text-slate-400 uppercase tracking-wider">Preview</label>
|
||||
<div class="preview-card rounded-lg p-3 space-y-1">
|
||||
<div class="text-[11px] font-semibold text-slate-500 uppercase tracking-wide">Playing</div>
|
||||
<div id="previewTitle" class="text-sm font-semibold text-slate-200">—</div>
|
||||
<div id="previewStatus" class="text-xs text-slate-400 hidden"></div>
|
||||
<div id="previewDetails" class="text-xs text-slate-400 hidden"></div>
|
||||
<div id="previewTime" class="text-xs text-slate-500 hidden">00:00 elapsed</div>
|
||||
</div>
|
||||
</section>
|
||||
</main>
|
||||
|
||||
<!-- Help Modal -->
|
||||
<div id="helpModal" class="fixed inset-0 z-50 hidden">
|
||||
<div class="modal-backdrop absolute inset-0" onclick="closeHelp()"></div>
|
||||
<div class="modal-content absolute inset-4 top-8 bottom-8 bg-surface-800 rounded-2xl border border-surface-600 flex flex-col overflow-hidden">
|
||||
|
||||
<!-- Modal header -->
|
||||
<div class="flex items-center justify-between px-5 py-4 border-b border-surface-600">
|
||||
<h2 class="text-sm font-semibold">Setup Guide</h2>
|
||||
<button onclick="closeHelp()"
|
||||
class="w-7 h-7 rounded-lg bg-surface-700 hover:bg-surface-600 flex items-center justify-center text-slate-400 hover:text-slate-200 transition-colors text-lg leading-none">
|
||||
×
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Modal body -->
|
||||
<div class="flex-1 overflow-y-auto px-5 py-4 space-y-6">
|
||||
|
||||
<!-- Section: Create an Application -->
|
||||
<div class="space-y-3">
|
||||
<h3 class="text-xs font-semibold text-accent uppercase tracking-wider">Create a Discord Application</h3>
|
||||
<p class="text-xs text-slate-400 leading-relaxed">
|
||||
Each application you create becomes a "game" Discord can display on your profile.
|
||||
The application name is what shows as <span class="text-slate-200 font-medium">Playing X</span> — so name it whatever you want people to see.
|
||||
</p>
|
||||
<div class="space-y-3">
|
||||
<div class="flex gap-3 items-start">
|
||||
<div class="step-number">1</div>
|
||||
<p class="text-sm text-slate-300 pt-0.5">Go to <span class="text-accent font-medium">discord.com/developers/applications</span> and log in.</p>
|
||||
</div>
|
||||
<div class="flex gap-3 items-start">
|
||||
<div class="step-number">2</div>
|
||||
<p class="text-sm text-slate-300 pt-0.5">Click <span class="text-slate-200 font-medium">New Application</span> in the top right.</p>
|
||||
</div>
|
||||
<div class="flex gap-3 items-start">
|
||||
<div class="step-number">3</div>
|
||||
<p class="text-sm text-slate-300 pt-0.5">Name it whatever you want to show as your "game" — this is the title that appears on your profile.</p>
|
||||
</div>
|
||||
<div class="flex gap-3 items-start">
|
||||
<div class="step-number">4</div>
|
||||
<p class="text-sm text-slate-300 pt-0.5">On the <span class="text-slate-200 font-medium">General Information</span> page, copy the <span class="text-slate-200 font-medium">Application ID</span> (the long number near the top).</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Section: Using the App -->
|
||||
<div class="space-y-3">
|
||||
<h3 class="text-xs font-semibold text-accent uppercase tracking-wider">Using the App</h3>
|
||||
<div class="space-y-3">
|
||||
<div class="flex gap-3 items-start">
|
||||
<div class="step-number">1</div>
|
||||
<p class="text-sm text-slate-300 pt-0.5">Paste the Application ID and click <span class="text-slate-200 font-medium">Connect</span>. Discord must be running on the same machine.</p>
|
||||
</div>
|
||||
<div class="flex gap-3 items-start">
|
||||
<div class="step-number">2</div>
|
||||
<p class="text-sm text-slate-300 pt-0.5">Type whatever you want in <span class="text-slate-200 font-medium">Status</span> and <span class="text-slate-200 font-medium">Details</span> (both optional). Hit <span class="text-slate-200 font-medium">Set Status</span>.</p>
|
||||
</div>
|
||||
<div class="flex gap-3 items-start">
|
||||
<div class="step-number">3</div>
|
||||
<p class="text-sm text-slate-300 pt-0.5">Use <span class="text-slate-200 font-medium">Clear</span> to remove the presence, or <span class="text-slate-200 font-medium">Disconnect</span> to drop the connection entirely.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Section: Elapsed Time -->
|
||||
<div class="space-y-3">
|
||||
<h3 class="text-xs font-semibold text-accent uppercase tracking-wider">Elapsed Time</h3>
|
||||
<p class="text-xs text-slate-400 leading-relaxed">
|
||||
The timer shows how long you've been "playing." Leave hours and minutes at 0 to start from now,
|
||||
or set a custom value to fake a longer session. Setting 48 hours makes it look like you've been at it for two days straight.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<!-- Section: Tips -->
|
||||
<div class="space-y-3">
|
||||
<h3 class="text-xs font-semibold text-accent uppercase tracking-wider">Tips</h3>
|
||||
<div class="bg-surface-700 rounded-lg p-3 space-y-2">
|
||||
<p class="text-xs text-slate-400 leading-relaxed">
|
||||
<span class="text-slate-300 font-medium">Changing the title:</span>
|
||||
The "Playing" title is locked to the Application name. To change it, rename the app in the developer portal,
|
||||
then disconnect and reconnect. Discord may take a minute to update.
|
||||
</p>
|
||||
<p class="text-xs text-slate-400 leading-relaxed">
|
||||
<span class="text-slate-300 font-medium">Multiple titles:</span>
|
||||
Create several Applications with different names and swap between their IDs to quickly change what you're "playing."
|
||||
</p>
|
||||
<p class="text-xs text-slate-400 leading-relaxed">
|
||||
<span class="text-slate-300 font-medium">Ghost entries:</span>
|
||||
If old game names linger, go to Discord → Settings → Activity Settings → Registered Games and remove them.
|
||||
</p>
|
||||
<p class="text-xs text-slate-400 leading-relaxed">
|
||||
<span class="text-slate-300 font-medium">No bot token needed.</span>
|
||||
This uses Discord's local IPC socket, not the bot gateway. No permissions, no OAuth, no server required.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Toast container -->
|
||||
<div id="toastContainer" class="fixed bottom-4 left-1/2 -translate-x-1/2 z-40 space-y-2"></div>
|
||||
|
||||
<script src="main.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
+194
@@ -0,0 +1,194 @@
|
||||
const { invoke } = window.__TAURI__.core;
|
||||
|
||||
let connected = false;
|
||||
let timerStart = null;
|
||||
let timerInterval = null;
|
||||
|
||||
const appIdInput = document.getElementById("appId");
|
||||
const statusInput = document.getElementById("statusInput");
|
||||
const detailsInput = document.getElementById("detailsInput");
|
||||
const showTimeCheck = document.getElementById("showTime");
|
||||
const connectBtn = document.getElementById("connectBtn");
|
||||
const setBtn = document.getElementById("setBtn");
|
||||
const clearBtn = document.getElementById("clearBtn");
|
||||
const statusDot = document.getElementById("statusDot");
|
||||
const statusLabel = document.getElementById("statusLabel");
|
||||
const previewTitle = document.getElementById("previewTitle");
|
||||
const previewStatus = document.getElementById("previewStatus");
|
||||
const previewDetails = document.getElementById("previewDetails");
|
||||
const previewTime = document.getElementById("previewTime");
|
||||
|
||||
async function toggleConnection() {
|
||||
if (connected) {
|
||||
try {
|
||||
await invoke("disconnect");
|
||||
setConnected(false);
|
||||
toast("Disconnected", "neutral");
|
||||
} catch (e) {
|
||||
toast(e, "error");
|
||||
}
|
||||
} else {
|
||||
const appId = appIdInput.value.trim();
|
||||
if (!appId) {
|
||||
toast("Paste your Application ID first", "error");
|
||||
appIdInput.focus();
|
||||
return;
|
||||
}
|
||||
connectBtn.textContent = "Connecting…";
|
||||
connectBtn.disabled = true;
|
||||
try {
|
||||
await invoke("connect", { appId });
|
||||
setConnected(true);
|
||||
toast("Connected to Discord", "success");
|
||||
} catch (e) {
|
||||
toast(e, "error");
|
||||
} finally {
|
||||
connectBtn.disabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function setConnected(state) {
|
||||
connected = state;
|
||||
connectBtn.textContent = state ? "Disconnect" : "Connect";
|
||||
statusDot.className = `status-dot ${state ? "on" : "off"}`;
|
||||
statusLabel.textContent = state ? "Connected" : "Disconnected";
|
||||
setBtn.disabled = !state;
|
||||
clearBtn.disabled = !state;
|
||||
appIdInput.disabled = state;
|
||||
|
||||
if (state) {
|
||||
timerStart = Date.now();
|
||||
startTimer();
|
||||
} else {
|
||||
stopTimer();
|
||||
timerStart = null;
|
||||
}
|
||||
}
|
||||
|
||||
async function setActivity() {
|
||||
const status = statusInput.value.trim();
|
||||
const details = detailsInput.value.trim();
|
||||
const showTime = showTimeCheck.checked;
|
||||
const hours = parseInt(document.getElementById("elapsedHours").value) || 0;
|
||||
const mins = parseInt(document.getElementById("elapsedMins").value) || 0;
|
||||
const elapsedSeconds = (hours * 3600) + (mins * 60);
|
||||
|
||||
try {
|
||||
await invoke("set_activity", { status, details, showTime, elapsedSeconds });
|
||||
if (elapsedSeconds > 0) {
|
||||
timerStart = Date.now() - (elapsedSeconds * 1000);
|
||||
}
|
||||
updatePreview(status, details, showTime);
|
||||
toast("Status updated", "success");
|
||||
} catch (e) {
|
||||
toast(e, "error");
|
||||
}
|
||||
}
|
||||
|
||||
async function clearActivity() {
|
||||
try {
|
||||
await invoke("clear_activity");
|
||||
resetPreview();
|
||||
toast("Presence cleared", "neutral");
|
||||
} catch (e) {
|
||||
toast(e, "error");
|
||||
}
|
||||
}
|
||||
|
||||
function updatePreview(status, details, showTime) {
|
||||
previewTitle.textContent = appIdInput.value ? "Your App Name" : "—";
|
||||
|
||||
if (status) {
|
||||
previewStatus.textContent = status;
|
||||
previewStatus.classList.remove("hidden");
|
||||
} else {
|
||||
previewStatus.classList.add("hidden");
|
||||
}
|
||||
|
||||
if (details) {
|
||||
previewDetails.textContent = details;
|
||||
previewDetails.classList.remove("hidden");
|
||||
} else {
|
||||
previewDetails.classList.add("hidden");
|
||||
}
|
||||
|
||||
if (showTime) {
|
||||
previewTime.classList.remove("hidden");
|
||||
} else {
|
||||
previewTime.classList.add("hidden");
|
||||
}
|
||||
}
|
||||
|
||||
function resetPreview() {
|
||||
previewTitle.textContent = "—";
|
||||
previewStatus.classList.add("hidden");
|
||||
previewDetails.classList.add("hidden");
|
||||
previewTime.classList.add("hidden");
|
||||
}
|
||||
|
||||
statusInput.addEventListener("input", () => {
|
||||
if (previewStatus.textContent || statusInput.value) {
|
||||
previewStatus.textContent = statusInput.value || "";
|
||||
previewStatus.classList.toggle("hidden", !statusInput.value);
|
||||
}
|
||||
});
|
||||
detailsInput.addEventListener("input", () => {
|
||||
if (previewDetails.textContent || detailsInput.value) {
|
||||
previewDetails.textContent = detailsInput.value || "";
|
||||
previewDetails.classList.toggle("hidden", !detailsInput.value);
|
||||
}
|
||||
});
|
||||
|
||||
statusInput.addEventListener("keydown", (e) => { if (e.key === "Enter" && connected) setActivity(); });
|
||||
detailsInput.addEventListener("keydown", (e) => { if (e.key === "Enter" && connected) setActivity(); });
|
||||
appIdInput.addEventListener("keydown", (e) => { if (e.key === "Enter" && !connected) toggleConnection(); });
|
||||
|
||||
function startTimer() {
|
||||
stopTimer();
|
||||
timerInterval = setInterval(() => {
|
||||
if (!timerStart) return;
|
||||
const elapsed = Math.floor((Date.now() - timerStart) / 1000);
|
||||
const h = Math.floor(elapsed / 3600);
|
||||
const m = Math.floor((elapsed % 3600) / 60);
|
||||
const s = elapsed % 60;
|
||||
const parts = [];
|
||||
if (h > 0) parts.push(String(h).padStart(2, "0"));
|
||||
parts.push(String(m).padStart(2, "0"));
|
||||
parts.push(String(s).padStart(2, "0"));
|
||||
previewTime.textContent = parts.join(":") + " elapsed";
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
function stopTimer() {
|
||||
if (timerInterval) {
|
||||
clearInterval(timerInterval);
|
||||
timerInterval = null;
|
||||
}
|
||||
}
|
||||
|
||||
function openHelp() {
|
||||
document.getElementById("helpModal").classList.remove("hidden");
|
||||
}
|
||||
|
||||
function closeHelp() {
|
||||
document.getElementById("helpModal").classList.add("hidden");
|
||||
}
|
||||
|
||||
document.addEventListener("keydown", (e) => {
|
||||
if (e.key === "Escape") closeHelp();
|
||||
});
|
||||
|
||||
function toast(msg, type = "neutral") {
|
||||
const container = document.getElementById("toastContainer");
|
||||
const colors = {
|
||||
success: "bg-emerald-900/80 border-emerald-700/50 text-emerald-200",
|
||||
error: "bg-rose-900/80 border-rose-700/50 text-rose-200",
|
||||
neutral: "bg-surface-700/90 border-surface-600/50 text-slate-300",
|
||||
};
|
||||
const el = document.createElement("div");
|
||||
el.className = `toast text-xs px-4 py-2 rounded-lg border backdrop-blur-sm ${colors[type] || colors.neutral}`;
|
||||
el.textContent = msg;
|
||||
container.appendChild(el);
|
||||
setTimeout(() => el.remove(), 2600);
|
||||
}
|
||||
Reference in New Issue
Block a user