mirror of
https://github.com/agresdominik/file-leak.git
synced 2026-04-21 18:05:48 +00:00
Proof of concept
This commit is contained in:
@@ -0,0 +1,89 @@
|
||||
// Handling of adding saving and loading list entries
|
||||
|
||||
function addEntry(domain, path) {
|
||||
|
||||
const list = document.getElementById("entry-list");
|
||||
|
||||
const entry = document.createElement("div");
|
||||
entry.className = "entry";
|
||||
|
||||
const domainField = document.createElement("span");
|
||||
domainField.textContent = domain;
|
||||
|
||||
const pathField = document.createElement("span");
|
||||
pathField.textContent = path;
|
||||
|
||||
const deleteButton = document.createElement("button");
|
||||
deleteButton.textContent = "Delete";
|
||||
deleteButton.addEventListener("click", function () {
|
||||
entry.remove();
|
||||
saveAllEntries();
|
||||
})
|
||||
|
||||
const openButton = document.createElement("button");
|
||||
openButton.textContent = "Open";
|
||||
openButton.addEventListener("click", function () {
|
||||
const url = pathField.textContent;
|
||||
if (url) {
|
||||
window.open(url, "_blank");
|
||||
}
|
||||
});
|
||||
|
||||
entry.appendChild(domainField);
|
||||
entry.appendChild(pathField);
|
||||
entry.appendChild(deleteButton);
|
||||
entry.appendChild(openButton);
|
||||
|
||||
list.appendChild(entry);
|
||||
|
||||
saveAllEntries();
|
||||
}
|
||||
|
||||
function saveAllEntries() {
|
||||
const entries = [];
|
||||
|
||||
document.querySelectorAll(".entry").forEach(entry => {
|
||||
const spans = entry.querySelectorAll("span");
|
||||
entries.push({
|
||||
domainField: spans[0].textContent,
|
||||
pathField: spans[1].textContent
|
||||
});
|
||||
});
|
||||
|
||||
browser.storage.local.set({ entries });
|
||||
}
|
||||
|
||||
async function loadEntries() {
|
||||
const stored = await browser.storage.local.get("entries");
|
||||
if (!stored.entries) return;
|
||||
|
||||
for (const data of stored.entries) {
|
||||
addEntry(data.domainField, data.pathField);
|
||||
}
|
||||
}
|
||||
|
||||
// Load entries when popup starts
|
||||
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
loadEntries();
|
||||
});
|
||||
|
||||
// Handle persistance for toggle button
|
||||
|
||||
const toggle = document.getElementById("listenerToggle");
|
||||
|
||||
browser.storage.local.get("listenerEnabled").then(({ listenerEnabled }) => {
|
||||
toggle.checked = !!listenerEnabled;
|
||||
});
|
||||
|
||||
toggle.addEventListener("change", (e) => {
|
||||
const enabled = e.target.checked;
|
||||
browser.storage.local.set({ listenerEnabled: enabled });
|
||||
browser.runtime.sendMessage({ type: "toggleListener", enabled });
|
||||
});
|
||||
|
||||
// Run one scan on button press
|
||||
|
||||
document.getElementById("runOnceBtn").addEventListener("click", () => {
|
||||
browser.runtime.sendMessage({ type: "runOnce" });
|
||||
});
|
||||
Reference in New Issue
Block a user