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,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")