我目前正在尝试弄清楚如何通过扩展程序在Chrome浏览器上自动执行屏幕捕获。我已到达chrome.tabs.captureVisibleTab
,但遇到了一个奇怪的问题:
chrome.tabs.update(tabId, { active: true }, function() {
chrome.tabs.captureVisibleTab(null, {}, function(data) {
// Going to canvas that data so hard...
// The system's going think it's tainted
});
});
以上内容失败并显示以下消息:
Unchecked runtime.lastError while running tabs.captureVisibleTab: Failed to capture tab: unknown error
at Object.capture [as callback]
但是,如果我将其更改为以下内容:
chrome.tabs.update(tabId, { active: true }, function() {
setTimeout(function() {
chrome.tabs.captureVisibleTab(null, {}, function(data) {
// Going to canvas that data so hard...
// The system's going think it's tainted
});
}, 0);
});
代码经历没有问题。但是,回调最终是异步的。我的扩展目前可以“并行”自动化多个选项卡。我担心在执行第一个chrome.tabs.update
之前可能会有多个chrome.tabs.captureVisibleTab
被调用。
思考?我忽略了什么?还是一个潜在的错误?任何见解都非常感谢。
答案 0 :(得分:0)
在manifest.json中尝试$(document).ready(function() {
$("#chatBubble").click(function(){
//console.log("clicked")
('#wrapper').show();
})
});
。这为我解决了。