0

我编写了一个 chrome 扩展程序,它可以获取可见选项卡的屏幕截图。现在,我希望扩展程序在一定时间间隔后自动拍照,而无需按下按钮。那怎么可能呢?

4

1 回答 1

1

它应该很简单,只需使用 JavascriptsetTimeoutsetInterval.

var seconds = 10 * 1000;
var windowId = some window id;
setTimeout(function() { 
  chrome.tabs.captureVisibleTab(
    some window id, 
    {}, 
    function () { ... do something with the screen shot ;} )
  }
, seconds);

这将在 10 秒后截取屏幕截图。要每隔几秒对可见选项卡进行截图,请使用setInterval

var seconds = 10 * 1000;
var windowId = some window id;
setInterval(function() { 
  chrome.tabs.captureVisibleTab(
    some window id, 
    {}, 
    function () { ... do something with the screen shot ;} )
  }
, seconds);
于 2011-06-06T14:04:15.880 回答