user23266137
user23266137

Reputation: 11

I'm building a safari extension. How can I take a screenshot of non visible part?

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

Answers (1)

user23266137
user23266137

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

Related Questions