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,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")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue