Chrome扩展程序后台,如何将captureVisibleTab发送到要显示的html文件?

问题描述

嘿,所以我想在单击图标按钮时打开一个新选项卡,其中包含上一页的屏幕截图。我正在尝试将chrome.tabs.captureVisibleTab屏幕截图发送到html页面,以便我可以显示屏幕截图。这是我的代码

Background.js

echo "
.mode csv
.import a.csv atable
.import b.csv btable
create table result as select * from atable EXCEPT select * from btable;
.output result.csv
select * from result ;
.quit
" | sqlite3 temp.db

screenshot.html

console.log("Background running");

var screenshot = {
    data : '',init : function() {
    this.initEvents();
    },initEvents : function () {
    chrome.browserAction.onClicked.addListener(function(tab) {
      chrome.tabs.captureVisibleTab(null,{
        format: "png",quality:100
      },function(screenshotUrl){
        screenshot.data = screenshotUrl;
        console.log(screenshotUrl);

      var newURL = "screenshot.html";
      chrome.tabs.create({ url: newURL });
      });
    });

  }
}

screenshot.init();

manifest.json

<html>
<head>
<title>Hello World</title>
<img src="myScreenshot.png" alt="png">
</head>
</html>

我该怎么做?谢谢!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)