Add options page with vector controls, whitelist, and container management
- Options page (open_in_tab) with 4 sections: fingerprint vector toggles, domain whitelist, container table with delete, and bulk actions - Per-vector spoofing control: 12 independent toggles (canvas, WebGL, audio, navigator, screen, timezone, WebRTC, fonts, clientRects, plugins, battery, connection) - Domain whitelist bypasses containerization entirely - Delete individual containers from options UI - Remove dead code (tabOrigins, getContainerDomain) - Refactor profile registration into buildProfileAndRegister helper
This commit is contained in:
71
options/options.css
Normal file
71
options/options.css
Normal file
@@ -0,0 +1,71 @@
|
||||
* { margin: 0; padding: 0; box-sizing: border-box; }
|
||||
body { font: 13px/1.4 system-ui, sans-serif; color: #e0e0e0; background: #1e1e2e; }
|
||||
.wrap { max-width: 640px; margin: 0 auto; padding: 24px 20px; }
|
||||
|
||||
header { display: flex; align-items: baseline; gap: 10px; padding-bottom: 12px; border-bottom: 1px solid #333; margin-bottom: 24px; }
|
||||
h1 { font-size: 18px; font-weight: 600; }
|
||||
#version { font-size: 11px; color: #888; }
|
||||
|
||||
section { margin-bottom: 28px; }
|
||||
h2 { font-size: 14px; font-weight: 600; padding-bottom: 6px; border-bottom: 1px solid #2a2a3a; margin-bottom: 8px; }
|
||||
.desc { font-size: 11px; color: #888; margin-bottom: 10px; }
|
||||
|
||||
/* Vector grid */
|
||||
#vector-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
|
||||
.vector-item { display: flex; align-items: center; justify-content: space-between; padding: 6px 10px; background: #2a2a3a; border-radius: 4px; }
|
||||
.vector-label { font-size: 12px; }
|
||||
|
||||
/* Toggle switch (matches popup) */
|
||||
.toggle { appearance: none; width: 32px; height: 18px; background: #444; border-radius: 9px; position: relative; cursor: pointer; flex-shrink: 0; }
|
||||
.toggle::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; background: #888; border-radius: 50%; transition: .15s; }
|
||||
.toggle:checked { background: #4a9eff; }
|
||||
.toggle:checked::after { left: 16px; background: #fff; }
|
||||
|
||||
/* Whitelist */
|
||||
.whitelist-input { display: flex; gap: 6px; margin-bottom: 8px; }
|
||||
.whitelist-input input { flex: 1; padding: 6px 8px; background: #2a2a3a; border: 1px solid #444; border-radius: 4px; color: #e0e0e0; font-size: 12px; outline: none; }
|
||||
.whitelist-input input:focus { border-color: #4a9eff; }
|
||||
#wl-list { display: flex; flex-wrap: wrap; gap: 6px; }
|
||||
.wl-chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; background: #2a2a3a; border: 1px solid #444; border-radius: 12px; font-size: 11px; }
|
||||
.wl-chip button { background: none; border: none; color: #888; cursor: pointer; font-size: 13px; line-height: 1; padding: 0 2px; }
|
||||
.wl-chip button:hover { color: #ff613d; }
|
||||
|
||||
/* Container table */
|
||||
table { width: 100%; border-collapse: collapse; }
|
||||
th { text-align: left; font-size: 11px; color: #888; font-weight: 400; padding: 4px 8px; border-bottom: 1px solid #333; }
|
||||
td { padding: 6px 8px; border-bottom: 1px solid #2a2a3a; }
|
||||
tr:hover td { background: #2a2a3a; }
|
||||
.empty { font-size: 12px; color: #888; padding: 12px 0; }
|
||||
|
||||
/* Color dots (matches popup) */
|
||||
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; }
|
||||
.dot-blue { background: #37adff; }
|
||||
.dot-turquoise { background: #00c79a; }
|
||||
.dot-green { background: #51cd00; }
|
||||
.dot-yellow { background: #ffcb00; }
|
||||
.dot-orange { background: #ff9f00; }
|
||||
.dot-red { background: #ff613d; }
|
||||
.dot-pink { background: #ff4bda; }
|
||||
.dot-purple { background: #af51f5; }
|
||||
.dot-toolbar { background: #888; }
|
||||
|
||||
/* Buttons */
|
||||
.btn { padding: 6px 12px; background: #333; border: 1px solid #555; color: #ccc; border-radius: 4px; cursor: pointer; font-size: 12px; }
|
||||
.btn:hover { background: #444; color: #fff; }
|
||||
.secondary { background: #2a2a3a; color: #aaa; }
|
||||
.secondary:hover { background: #333; color: #ddd; }
|
||||
.danger { background: #3a1a1a; border-color: #663333; color: #ff613d; }
|
||||
.danger:hover { background: #4a2020; color: #ff8866; }
|
||||
.btn-sm { padding: 2px 6px; font-size: 11px; }
|
||||
.btn-icon { background: none; border: 1px solid #555; color: #aaa; border-radius: 4px; padding: 2px 6px; font-size: 11px; cursor: pointer; }
|
||||
.btn-icon:hover { border-color: #888; color: #ddd; }
|
||||
.btn-del { background: none; border: 1px solid #553333; color: #ff613d; border-radius: 4px; padding: 2px 6px; font-size: 11px; cursor: pointer; }
|
||||
.btn-del:hover { border-color: #884444; color: #ff8866; }
|
||||
|
||||
.td-actions { display: flex; gap: 4px; justify-content: flex-end; }
|
||||
|
||||
/* Bulk actions */
|
||||
.bulk { display: flex; flex-direction: column; gap: 6px; }
|
||||
.bulk #regen-all { width: 100%; }
|
||||
.bulk-row { display: flex; gap: 6px; }
|
||||
.bulk-row button { flex: 1; }
|
||||
64
options/options.html
Normal file
64
options/options.html
Normal file
@@ -0,0 +1,64 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>ContainSite Options</title>
|
||||
<link rel="stylesheet" href="options.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="wrap">
|
||||
<header>
|
||||
<h1>ContainSite</h1>
|
||||
<span id="version"></span>
|
||||
</header>
|
||||
|
||||
<main>
|
||||
<section>
|
||||
<h2>Fingerprint Vectors</h2>
|
||||
<p class="desc">Control which fingerprint vectors are spoofed. Changes take effect on next page load.</p>
|
||||
<div id="vector-grid"></div>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<h2>Domain Whitelist</h2>
|
||||
<p class="desc">Whitelisted domains are never containerized or fingerprint-spoofed.</p>
|
||||
<div class="whitelist-input">
|
||||
<input type="text" id="wl-input" placeholder="example.com" spellcheck="false">
|
||||
<button id="wl-add" class="btn">Add</button>
|
||||
</div>
|
||||
<div id="wl-list"></div>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<h2>Containers</h2>
|
||||
<p class="desc">All containers managed by ContainSite.</p>
|
||||
<table id="container-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th>Domain</th>
|
||||
<th>Spoofing</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="container-tbody"></tbody>
|
||||
</table>
|
||||
<div id="no-containers" class="empty" hidden>No containers yet. Browse a website to create one.</div>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<h2>Bulk Actions</h2>
|
||||
<div class="bulk">
|
||||
<button id="regen-all" class="btn">Regenerate All Fingerprints</button>
|
||||
<div class="bulk-row">
|
||||
<button id="prune" class="btn secondary">Prune Unused</button>
|
||||
<button id="reset" class="btn danger">Reset All</button>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</main>
|
||||
</div>
|
||||
|
||||
<script src="options.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
226
options/options.js
Normal file
226
options/options.js
Normal file
@@ -0,0 +1,226 @@
|
||||
const VECTORS = {
|
||||
canvas: "Canvas",
|
||||
webgl: "WebGL",
|
||||
audio: "Audio",
|
||||
navigator: "Navigator",
|
||||
screen: "Screen",
|
||||
timezone: "Timezone",
|
||||
webrtc: "WebRTC",
|
||||
fonts: "Fonts",
|
||||
clientRects: "Client Rects",
|
||||
plugins: "Plugins",
|
||||
battery: "Battery",
|
||||
connection: "Connection"
|
||||
};
|
||||
|
||||
// --- Vector Settings ---
|
||||
|
||||
async function loadVectors() {
|
||||
const settings = await browser.runtime.sendMessage({ type: "getVectorSettings" });
|
||||
const grid = document.getElementById("vector-grid");
|
||||
grid.innerHTML = "";
|
||||
|
||||
for (const [key, label] of Object.entries(VECTORS)) {
|
||||
const item = document.createElement("div");
|
||||
item.className = "vector-item";
|
||||
|
||||
const span = document.createElement("span");
|
||||
span.className = "vector-label";
|
||||
span.textContent = label;
|
||||
item.appendChild(span);
|
||||
|
||||
const toggle = document.createElement("input");
|
||||
toggle.type = "checkbox";
|
||||
toggle.className = "toggle";
|
||||
toggle.checked = settings[key] !== false;
|
||||
toggle.addEventListener("change", async () => {
|
||||
settings[key] = toggle.checked;
|
||||
toggle.disabled = true;
|
||||
await browser.runtime.sendMessage({ type: "setVectorSettings", vectorSettings: settings });
|
||||
toggle.disabled = false;
|
||||
});
|
||||
item.appendChild(toggle);
|
||||
|
||||
grid.appendChild(item);
|
||||
}
|
||||
}
|
||||
|
||||
// --- Whitelist ---
|
||||
|
||||
let currentWhitelist = [];
|
||||
|
||||
async function loadWhitelist() {
|
||||
currentWhitelist = await browser.runtime.sendMessage({ type: "getWhitelist" });
|
||||
renderWhitelist();
|
||||
}
|
||||
|
||||
function renderWhitelist() {
|
||||
const list = document.getElementById("wl-list");
|
||||
list.innerHTML = "";
|
||||
|
||||
for (const domain of currentWhitelist) {
|
||||
const chip = document.createElement("span");
|
||||
chip.className = "wl-chip";
|
||||
chip.textContent = domain;
|
||||
|
||||
const btn = document.createElement("button");
|
||||
btn.textContent = "\u00d7";
|
||||
btn.title = "Remove";
|
||||
btn.addEventListener("click", async () => {
|
||||
currentWhitelist = currentWhitelist.filter(d => d !== domain);
|
||||
await browser.runtime.sendMessage({ type: "setWhitelist", whitelist: currentWhitelist });
|
||||
renderWhitelist();
|
||||
});
|
||||
chip.appendChild(btn);
|
||||
list.appendChild(chip);
|
||||
}
|
||||
}
|
||||
|
||||
document.getElementById("wl-add").addEventListener("click", addWhitelistEntry);
|
||||
document.getElementById("wl-input").addEventListener("keydown", (e) => {
|
||||
if (e.key === "Enter") addWhitelistEntry();
|
||||
});
|
||||
|
||||
async function addWhitelistEntry() {
|
||||
const input = document.getElementById("wl-input");
|
||||
let domain = input.value.trim().toLowerCase();
|
||||
|
||||
// Strip protocol and path
|
||||
domain = domain.replace(/^https?:\/\//, "").replace(/\/.*$/, "");
|
||||
// Strip www.
|
||||
domain = domain.replace(/^www\./, "");
|
||||
|
||||
if (!domain || !domain.includes(".")) return;
|
||||
if (currentWhitelist.includes(domain)) { input.value = ""; return; }
|
||||
|
||||
currentWhitelist.push(domain);
|
||||
await browser.runtime.sendMessage({ type: "setWhitelist", whitelist: currentWhitelist });
|
||||
input.value = "";
|
||||
renderWhitelist();
|
||||
}
|
||||
|
||||
// --- Containers ---
|
||||
|
||||
async function loadContainers() {
|
||||
const containers = await browser.runtime.sendMessage({ type: "getContainerList" });
|
||||
const tbody = document.getElementById("container-tbody");
|
||||
const empty = document.getElementById("no-containers");
|
||||
tbody.innerHTML = "";
|
||||
|
||||
// Only show containers that have a seed (managed by us)
|
||||
const ours = containers.filter(c => c.hasSeed);
|
||||
|
||||
if (ours.length === 0) {
|
||||
empty.hidden = false;
|
||||
document.getElementById("container-table").hidden = true;
|
||||
return;
|
||||
}
|
||||
|
||||
empty.hidden = true;
|
||||
document.getElementById("container-table").hidden = false;
|
||||
|
||||
ours.sort((a, b) => (a.domain || a.name).localeCompare(b.domain || b.name));
|
||||
|
||||
for (const c of ours) {
|
||||
const tr = document.createElement("tr");
|
||||
|
||||
// Color dot
|
||||
const tdDot = document.createElement("td");
|
||||
const dot = document.createElement("span");
|
||||
dot.className = `dot dot-${c.color}`;
|
||||
tdDot.appendChild(dot);
|
||||
tr.appendChild(tdDot);
|
||||
|
||||
// Domain
|
||||
const tdDomain = document.createElement("td");
|
||||
tdDomain.textContent = c.domain || c.name;
|
||||
tr.appendChild(tdDomain);
|
||||
|
||||
// Enabled toggle
|
||||
const tdToggle = document.createElement("td");
|
||||
const toggle = document.createElement("input");
|
||||
toggle.type = "checkbox";
|
||||
toggle.className = "toggle";
|
||||
toggle.checked = c.enabled;
|
||||
toggle.addEventListener("change", async () => {
|
||||
await browser.runtime.sendMessage({
|
||||
type: "toggleContainer",
|
||||
cookieStoreId: c.cookieStoreId,
|
||||
enabled: toggle.checked
|
||||
});
|
||||
});
|
||||
tdToggle.appendChild(toggle);
|
||||
tr.appendChild(tdToggle);
|
||||
|
||||
// Actions
|
||||
const tdActions = document.createElement("td");
|
||||
tdActions.className = "td-actions";
|
||||
|
||||
const regen = document.createElement("button");
|
||||
regen.className = "btn-icon";
|
||||
regen.textContent = "New";
|
||||
regen.title = "Generate new fingerprint";
|
||||
regen.addEventListener("click", async () => {
|
||||
regen.textContent = "...";
|
||||
await browser.runtime.sendMessage({ type: "regenerateFingerprint", cookieStoreId: c.cookieStoreId });
|
||||
regen.textContent = "OK";
|
||||
setTimeout(() => { regen.textContent = "New"; }, 800);
|
||||
});
|
||||
tdActions.appendChild(regen);
|
||||
|
||||
const del = document.createElement("button");
|
||||
del.className = "btn-del";
|
||||
del.textContent = "Del";
|
||||
del.title = "Delete container";
|
||||
del.addEventListener("click", async () => {
|
||||
if (!confirm(`Delete container for ${c.domain || c.name}? Cookies and data for this site will be lost.`)) return;
|
||||
del.textContent = "...";
|
||||
await browser.runtime.sendMessage({ type: "deleteContainer", cookieStoreId: c.cookieStoreId });
|
||||
loadContainers();
|
||||
});
|
||||
tdActions.appendChild(del);
|
||||
|
||||
tr.appendChild(tdActions);
|
||||
tbody.appendChild(tr);
|
||||
}
|
||||
}
|
||||
|
||||
// --- Bulk Actions ---
|
||||
|
||||
document.getElementById("regen-all").addEventListener("click", async (e) => {
|
||||
e.target.textContent = "Regenerating...";
|
||||
await browser.runtime.sendMessage({ type: "regenerateAll" });
|
||||
e.target.textContent = "Done!";
|
||||
setTimeout(() => { e.target.textContent = "Regenerate All Fingerprints"; }, 800);
|
||||
});
|
||||
|
||||
document.getElementById("prune").addEventListener("click", async (e) => {
|
||||
e.target.textContent = "Pruning...";
|
||||
const result = await browser.runtime.sendMessage({ type: "pruneContainers" });
|
||||
e.target.textContent = `Removed ${result.pruned}`;
|
||||
setTimeout(() => {
|
||||
e.target.textContent = "Prune Unused";
|
||||
loadContainers();
|
||||
}, 1200);
|
||||
});
|
||||
|
||||
document.getElementById("reset").addEventListener("click", async (e) => {
|
||||
if (!confirm("Remove all ContainSite containers and data? You will need to log in to all sites again.")) return;
|
||||
e.target.textContent = "Resetting...";
|
||||
await browser.runtime.sendMessage({ type: "resetAll" });
|
||||
e.target.textContent = "Done!";
|
||||
setTimeout(() => {
|
||||
e.target.textContent = "Reset All";
|
||||
loadContainers();
|
||||
}, 1200);
|
||||
});
|
||||
|
||||
// --- Init ---
|
||||
|
||||
async function init() {
|
||||
const manifest = browser.runtime.getManifest();
|
||||
document.getElementById("version").textContent = `v${manifest.version}`;
|
||||
await Promise.all([loadVectors(), loadWhitelist(), loadContainers()]);
|
||||
}
|
||||
|
||||
init();
|
||||
Reference in New Issue
Block a user