create the screenshot functionality

This commit is contained in:
Michi 2024-11-06 20:18:19 +01:00
parent 3363ec9acf
commit f32a3b56ce
4 changed files with 52 additions and 3 deletions

View file

@ -2,6 +2,18 @@
chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
console.log(message.action);
if (message.action == "captureScreenshot"){
chrome.tabs.captureVisibleTab(null, { format: "jpeg" }, (dataUrl) => {
if (chrome.runtime.lastError) {
console.error("Error capturing screenshot: ", chrome.runtime.lastError);
sendResponse({ success: false, error: chrome.runtime.lastError });
return;
}
sendResponse({ success: true, screenshot: dataUrl });
});
return true;
}
/*chrome.scripting.executeScript({
target: {tabId: tabs[0].id},
files: ['test.js']