mirror of
https://github.com/michivonah/click-guide.git
synced 2025-12-22 22:16:28 +01:00
beginn development of MVP
This commit is contained in:
parent
38ef57f310
commit
cfb4959168
12 changed files with 138 additions and 0 deletions
35
chrome/content.js
Normal file
35
chrome/content.js
Normal 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();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue