Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google chrome extension tabs.captureVisibleTab期间出错?在最近的Chrome更新之后_Google Chrome Extension - Fatal编程技术网

Google chrome extension tabs.captureVisibleTab期间出错?在最近的Chrome更新之后

Google chrome extension tabs.captureVisibleTab期间出错?在最近的Chrome更新之后,google-chrome-extension,Google Chrome Extension,最近更新了chrome浏览器后,我使用的一个旧应用程序——书签管理器——停止了工作。更具体地说,获取缩略图截图的部分不起作用。 错误消息是 “制表期间出错。captureVisibleTab:无法访问url的内容。” "chrome://newtab/#20“。扩展清单必须请求对 访问此主机。“ 据我所知,tabs.captureVisibleTab不应该在上面工作 铬:// 标签等 以下是manifest.json权限: "permissions": [ "storage","bookmark

最近更新了chrome浏览器后,我使用的一个旧应用程序——书签管理器——停止了工作。更具体地说,获取缩略图截图的部分不起作用。 错误消息是

“制表期间出错。captureVisibleTab:无法访问url的内容。” "chrome://newtab/#20“。扩展清单必须请求对 访问此主机。“

据我所知,tabs.captureVisibleTab不应该在上面工作

铬://

标签等

以下是manifest.json权限:

"permissions": [ "storage","bookmarks", "tabs", "history", "management", "unlimitedStorage", "chrome://favicon/", "http://*/*", "https://*/*","<all_urls>", "contextMenus", "notifications" ],
问题-大多数时候控制台都会触发此错误消息。每过一段时间,代码就会得到缩略图。据我所知,tabs.captureVisibleTab会在预定的时间之前触发

<> P>我会考虑有效的答案,无论是代码的直接修复(更好)还是一般的方向如何使它更可靠。 我的系统-Ubuntu 12.04,Chrome 24.0.1312.70
  • chrome.tabs.getSelected
    不推荐使用chrome.tabs.query
  • 不需要在chrome.tabs.captureVisibleTab中显式声明null(默认为null)
  • 参考文献

    如果这是导致问题的唯一原因,我将尝试并向上投票。我仍然必须通过chrome.tabs.query传递正确的id?在我看来,当我离开应用程序页面时,所有功能都会停止…感谢您的帮助-这与正常情况大不相同,但您不可能知道-code在backgorund.html中,而不是background.js中,并且不是根据版本2清单要求声明的
        function getThumbnail(url, showInfoWarning) {
        chrome.tabs.getSelected( null,function(tab) { 
          speeddial.storage.removeThumbnail(url);
            localStorage['requestThumbnail'] = tab.id+'|||'+url; 
            openInCurrent(url); 
        }); 
    }
    
    function makeThumbnail(url,captureDelay) {
    setTimeout(function() 
    {
        chrome.tabs.captureVisibleTab(null,{format:'png'},function(dataurl)
        {
            var canvas = document.createElementNS( "http://www.w3.org/1999/xhtml", "html:canvas" );
            var ctx = canvas.getContext('2d');      
            var img = document.createElement('img');
            img.onload = function()
            {
                try
                {
                    resized_width = 480; 
                    quality = 0.72;
    
                    if          (localStorage['options.thumbnailQuality']=='low')       { resized_width = 360; quality = 0.75;  }
                    if          (localStorage['options.thumbnailQuality']=='high')      { resized_width = 720; quality = 0.65;  }
    
                    resized_height =  Math.ceil((resized_width/img.width)*img.height);
                    canvas.width=resized_width
                    canvas.height=resized_height
                    ctx.drawImage(img,0,0,resized_width,resized_height);
    
                    localStorage.setItem(url, dataurl);
          // SPEED DIAL DB 
          // var speeddialdb = {};
          // speeddialdb.storage = {};
          // speeddialdb.storage.db = null;
          // var dbSize = 1 * 1024 * 1024; // 2MB
          // speeddialdb.storage.db = null;
          // speeddialdb.storage.db = openDatabase('bookmarks', '1.0', 'Speeddial2', dbSize);
    
          // speeddialdb.storage.db.transaction(function(tx) {
          //   tx.executeSql('DELETE FROM thumbnails WHERE url = ?', [url],function(){
          //     tx.executeSql('INSERT INTO thumbnails (url, thumbnail) values (?, ?)', [url, canvas.toDataURL("image/jpeg",quality)], null ,function(tx, e){alert('Something unexpected happened: ' + e.message ) });  
          //   });
          // });
                }
                catch(e){console.log(e)}            
            }
            img.src=dataurl;
        });
    }, captureDelay);
    }
    
    chrome.tabs.onUpdated.addListener(function(id,object,tab) {
        if (tab.selected && tab.url) {
            if (localStorage['requestThumbnail']!='' && localStorage['requestThumbnail']!="undefined" && typeof localStorage["requestThumbnail"]!='undefined') {
          var requestThumbnail = localStorage['requestThumbnail'].split('|||');
    
          if (requestThumbnail[0] == tab.id) { 
            if ( tab.status=="complete" ) { 
                if (tab.url.indexOf('mail.google.com')>-1 || tab.url.indexOf('twitter.com')>-1) 
                {
                    makeThumbnail(requestThumbnail[1],1000); 
                } else {
                    makeThumbnail(requestThumbnail[1],500); 
                }
                localStorage['requestThumbnail']='';
            }
            requestThumbnail = null;
          }
    
        } 
        }
    });