mirror of
https://github.com/michivonah/click-guide.git
synced 2025-12-22 22:16:28 +01:00
making basic functionality work & add todo list to readme
This commit is contained in:
parent
f32a3b56ce
commit
a84d0a512e
5 changed files with 88 additions and 18 deletions
|
|
@ -1,8 +1,33 @@
|
|||
// Script for Popup
|
||||
|
||||
const toggleRecordingBtn = document.getElementById("toggleRecording");
|
||||
const exportBtn = document.getElementById("exportBtn");
|
||||
|
||||
toggleRecordingBtn.addEventListener('click', () => {
|
||||
console.log("Button clicked");
|
||||
chrome.runtime.sendMessage({action: 'triggerName'});
|
||||
});
|
||||
});
|
||||
|
||||
exportBtn.addEventListener('click', () => {
|
||||
console.log("Export requested");
|
||||
chrome.runtime.sendMessage({
|
||||
action: "generateGuide"
|
||||
}, (response) => {
|
||||
const guide = response.guide;
|
||||
exportJSON(guide, "guide.json");
|
||||
});
|
||||
});
|
||||
|
||||
function exportJSON(object, filename){
|
||||
const json = JSON.stringify(object, null, 2);
|
||||
|
||||
const blob = new Blob([json], { type: "application/json" });
|
||||
const url = URL.createObjectURL(blob);
|
||||
|
||||
const link = document.createElement("a");
|
||||
link.href = url;
|
||||
link.download = filename;
|
||||
link.click();
|
||||
|
||||
URL.revokeObjectURL(url);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue