revert to scratch & create basic chrome extension

This commit is contained in:
Michi 2024-11-06 18:07:23 +01:00
parent cfb4959168
commit 3363ec9acf
5 changed files with 40 additions and 98 deletions

View file

@ -1,32 +1,9 @@
let steps = [];
// Background Worker
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
if (request.action === "start") {
steps = []; // Leeren, falls eine neue Aufzeichnung beginnt
chrome.storage.local.set({ recording: true });
} else if (request.action === "stop") {
chrome.storage.local.set({ recording: false });
downloadJSON(); // JSON anzeigen oder herunterladen
} else if (request.action === "captureStep") {
steps.push(request.step);
}
});
function downloadJSON() {
const guide = {
title: "Guide Title",
description: "Description of the guide",
date: new Date().toISOString().split("T")[0],
author: "Me",
steps: steps
};
const json = JSON.stringify(guide, null, 2);
const blob = new Blob([json], { type: "application/json" });
const url = URL.createObjectURL(blob);
chrome.downloads.download({
url: url,
filename: "guide.json"
});
}
chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
console.log(message.action);
/*chrome.scripting.executeScript({
target: {tabId: tabs[0].id},
files: ['test.js']
});*/
});