diff --git a/chrome/background.js b/chrome/background.js index c8ec49a..39a4b01 100644 --- a/chrome/background.js +++ b/chrome/background.js @@ -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'] + });*/ +}); \ No newline at end of file diff --git a/chrome/content.js b/chrome/content.js index c13c0a5..b902d53 100644 --- a/chrome/content.js +++ b/chrome/content.js @@ -1,35 +1,4 @@ -let recording = false; - -chrome.storage.local.get("recording", (data) => { - recording = data.recording || false; -}); - -chrome.storage.onChanged.addListener((changes) => { - if (changes.recording) { - recording = changes.recording.newValue; - } -}); - -document.addEventListener("click", async (event) => { - if (!recording) return; - - const elementSelector = getElementSelector(event.target); - - chrome.tabs.captureVisibleTab(null, { format: "jpeg" }, (image) => { - const step = { - label: `Click on ${elementSelector}`, - description: "Short description of the step", - action: "click", - element: elementSelector, - image: image - }; - - chrome.runtime.sendMessage({ action: "captureStep", step: step }); - }); -}); - -function getElementSelector(element) { - if (element.id) return `#${element.id}`; - if (element.className) return `.${element.className.split(" ").join(".")}`; - return element.tagName.toLowerCase(); -} +// Script which is executed on all web pages +//document.body.style.background = "blue"; +document.body.style.border = "red 20px solid"; +console.log("Ich bin hier") diff --git a/chrome/manifest.json b/chrome/manifest.json index 0c28270..c377b8b 100644 --- a/chrome/manifest.json +++ b/chrome/manifest.json @@ -1,24 +1,24 @@ { - "manifest_version": 3, - "name": "Cl1ck Gu1de", - "version": "0.0.1", - "description": "A browser add-on which records the steps clicked on a page and generates a easy to understand guide from it.", - "background": { - "service_worker": "background.js" - }, - "permissions": ["tabs", "activeTab", "scripting"], - "action": { - "default_popup": "popup.html", - "default_icon": { + "manifest_version": 3, + "name": "Cl1ck Gu1de", + "version": "0.0.2", + "description": "A browser add-on which records the steps clicked on a page and generates a easy to understand guide from it.", + "permissions": ["scripting", "activeTab", "downloads", "tabCapture", "tabs"], + "background": { + "service_worker": "background.js" + }, + "action": { + "default_popup": "popup.html", + "default_icon": { "16": "assets/logo/color/logo16x16.png", "48": "assets/logo/color/logo48x48.png", "128": "assets/logo/color/logo128x128.png" } - }, - "content_scripts":[ - { - "matches": [""], - "js": ["content.js"] - } - ] - } \ No newline at end of file + }, + "content_scripts": [ + { + "matches": [""], + "js": ["content.js"] + } + ] +} \ No newline at end of file diff --git a/chrome/popup.html b/chrome/popup.html index 2a47354..dbf97b6 100644 --- a/chrome/popup.html +++ b/chrome/popup.html @@ -1,15 +1,14 @@ - Cl1ck Gu1de

Cl1ck Gu1de

- + diff --git a/chrome/popup.js b/chrome/popup.js index 95435a7..4947e39 100644 --- a/chrome/popup.js +++ b/chrome/popup.js @@ -1,10 +1,7 @@ -let isRecording = false; +// Script for Popup +const toggleRecordingBtn = document.getElementById("toggleRecording"); -document.addEventListener("DOMContentLoaded", () => { - document.getElementById("toggle-recording").addEventListener("click", () => { - isRecording = !isRecording; - const message = isRecording ? "start" : "stop"; - chrome.runtime.sendMessage({ action: message }); - document.getElementById("toggle-recording").textContent = isRecording ? "Stop Recording" : "Start Recording"; - }); -}); +toggleRecordingBtn.addEventListener('click', () => { + console.log("Button clicked"); + chrome.runtime.sendMessage({action: 'triggerName'}); +}); \ No newline at end of file