Reputation: 11
I'm building an extension for safari.
I'm using captureVisibleTab
to take a screenshot. But it has a problem. When I scroll down the page, it doesn't capture the top of the page. I know it's a default behavior, but I want to take a screenshot of the top of the page even when I scroll it down.
I don't need to take a whole page, I just want to take a screenshot from the top of the page.
How can I achieve it?
I found chrome.desktopCapture but it seems it's only for chrome.
Upvotes: 0
Views: 35
Reputation: 11
It was simple. I could scrolling up to the top of the page by adding the following code in background.js.
background.js:
await browser.scripting.executeScript({
target: { tabId: tabId },
func: () => {
window.scrollTo(0, 0);
},
});
Also, I added scripting
in permissions
in manifest.
Upvotes: 0