- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我目前正在尝试弄清楚如何通过扩展程序在 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.captureVisibleTab
之前,可能会调用多个 chrome.tabs.update
。
想法?我忽略了什么?还是潜在的错误?非常感谢任何见解。
最佳答案
尝试 "permissions": [ "tabs", "<all_urls>" ]
在 manifest.json 中。这为我解决了问题。
关于javascript - chrome.tabs.captureVisibleTab 在 chrome.tabs.update 之后作为同步回调失败?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36854483/
captureVisibleTab [docs]在我的 Google Chrome 扩展程序中似乎不适合我,我一直试图让它在基于浏览器操作的扩展程序中运行,但返回的图像是 undefined每次。然后
我正在开发一个 Chrome 扩展程序。您将如何删除 captureVisibleTab 拍摄的图像?我担心无关的未使用图像会堵塞用户存储。 最佳答案 该方法不会创建物理文件,它只是向您传递数据 UR
我正在尝试在内容脚本中使用 captureVisibleTab chrome 扩展 API,以便可以在后台运行时捕获每个页面。 据我所知,这必须使用消息传递来完成。有人可以给我一个关于如何实现这一目标
当我使用 captureVisibleTab 在 Chrome 中捕获选项卡时,像素是使用 CMD+Shift+4 拖动/Esc 时看到的像素的两倍 如何确定像素密度的实际值? 最佳答案 您可以使用
我正在 try catch 当前可见的选项卡,但我收到未定义的信息。 当扩展程序的图标被按下时,下面的代码正在执行。当警报被调用时,我看到的是 undefined 而不是 URL。 chrome.br
我正在构建一个 Chrome 扩展,并试图从 chrome.tabs.captureVisibleTab() 内部向我的事件 background.js 页面发送消息。由于某种原因,消息不会发送到我的
我知道,你可以用 Chrome 扩展程序来截取网站的屏幕截图:chrome.tabs.captureVisibleTab(null, {format: 'png'}, captureImage); 但
我正在尝试使用 chrome.tabs.captureVisibleTab 捕获页面的可见区域。这是进行调用的代码: chrome.extension.onMessage.addListener(fu
当我在页面上使用 captureVisibleTab 并在 CSS3 中放置一个带有 preserve3d 的 div 时,我得到了空白页面:/ 我该如何解决? 我捕获屏幕浏览器的简单代码: chr
我很好奇是否可以使用 chrome.tabs.captureVisibleTab(无论是从控制台还是从代码片段中)直接从 Chrome 的开发工具中截取屏幕截图,而无需经历创建扩展的过程。 这有可能吗
我正在尝试使用 Chrome 扩展程序捕获可见选项卡。我已经设法让图像显示在另一个选项卡中以检查其工作情况。但我实际上想要拍摄图像,将其以 PNG 格式保存在用户计算机上的临时文件中。然后最终被发送到
我的总体目标是通过后台页面截屏,使用: http://developer.chrome.com/extensions/tabs.html#method-captureVisibleTab 并将它传递给
我正在使用以下代码来捕获所选选项卡的屏幕截图 chrome.tabs.captureVisibleTab( undefined, function( data ) { display( data )
我目前正在尝试弄清楚如何通过扩展程序在 Chrome 浏览器上自动捕获屏幕。我已经到达 chrome.tabs.captureVisibleTab 但遇到了一个奇怪的问题: chrome.tabs.u
我是 Chrome 扩展程序/自动下载领域的新手。我有一个背景页面,它使用 chrome.tabs.captureVisibleTab() 截取可见网页的屏幕截图。在我的弹出窗口中,我有: chrom
我是一名优秀的程序员,十分优秀!