Google Chrome插件会在新窗口中打开屏幕截图,但是如何将图像保存在我的计算机上呢?每次再次运行此脚本时,图像如何覆盖自身?代码是用Javascript编写的。
capturePage: function (position, lastCapture) {
var self = this;
setTimeout(function () {
chrome.tabs.captureVisibleTab(null, {
"format": "png"
}, function (dataURI) {
var newWindow,
image = new Image();
if (typeof dataURI !== "undefined") {
image.onload = function() {
self.screenshotContext.drawImage(image, 0, position);
if (lastCapture) {
self.resetPage();
newWindow = window.open();
newWindow.document.write("<style type='text/css'>body {margin: 0;}</style>");
newWindow.document.write("<img src='" + self.screenshotCanvas.toDataURL("image/png") + "'/>");
} else {
self.scrollTo(position + self.scrollBy);
}
};
image.src = dataURI;
} else {
chrome.tabs.sendMessage(self.tabId, {
"msg": "showError",
"originalParams": self.originalParams
});
}
});
}, 300);
},