mirror of
https://github.com/michivonah/click-guide.git
synced 2025-12-22 22:16:28 +01:00
revert to scratch & create basic chrome extension
This commit is contained in:
parent
cfb4959168
commit
3363ec9acf
5 changed files with 40 additions and 98 deletions
|
|
@ -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']
|
||||
});*/
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue