beginn development of MVP

This commit is contained in:
Michi 2024-10-27 14:50:53 +01:00
parent 38ef57f310
commit cfb4959168
12 changed files with 138 additions and 0 deletions

35
chrome/content.js Normal file
View file

@ -0,0 +1,35 @@
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();
}