2015-06-24 10 views
6

Bu nedenle, www.script.google.com gibi harici bir kaynaktan bir komut dosyası çalıştırmaya çalışıyorum. background.js.chrome.tabs.executeScript thows hatası "Tabs.executeScript çalışırken denetlenmeyen runtime.lastError: URL içeriğine erişilemiyor ..."

Unchecked runtime.lastError while running tabs.executeScript: Cannot access contents of url "chrome-devtools://devtools/bundled/devtools.html?&remoteBase=https://chrome…&dockSide=undocked&toolbarColor=rgba(223,223,223,1)&textColor=rgba(0,0,0,1)". Extension manifest must request permission to access this host. 

Ne ben popup.js gelen mesaj gönderiyor yapıyorum popup.js olarak background.js için - -

chrome.runtime.sendMessage({type:"addtask"}); 

background.js yılında -

Ama bu hatayı alıyorum
chrome.runtime.onMessage.addListener(function(request, sender, sendResponse){ 
    if(request.type == "addtask") 
    { 
     chrome.tabs.executeScript(null, 
         {file:"https://script.google.com/url of script....."}); 
    } 
}); 

Benim manifest.json-

{ 
    "name": "Extension", 
    "version": "0.0.1", 
    "manifest_version": 2, 
    "browser_action": { 
     "default_popup": "popup.html" 
    }, 
    "background": { 
     "scripts": ["background.js"], 
     "persistent": false 
    }, 
    "content_scripts": [{ 
     "js": ["jquery.min.js","contentscript.js"], 
     "matches": ["http://*/*","https://*/*"], 
     "css" : ["feedback.css"] 
    }], 
    "permissions": [ 
      "storage","tabs","https://script.google.com" 
     ], 
    "web_accessible_resources": ["feedback.js","html2canvas.js","event.js"], 
    "content_security_policy": "script-src 'self' https://script.google.com/*; object-src 'self'" 
} 
+1

bu hatayı tetikleyen ilgili kodu ekleyin: Burada

doğru taşıma hataları tüm sekmelerde bir senaryo yürütme ve bir örneğidir. – Xan

+0

@Xan Kodu ekledim. – Sid

+0

Niyetiniz% 100 net değil. Harici komut dosyasını bir içerik komut dosyası veya arka plan komut dosyası olarak çalıştırmaya mı çalışıyorsunuz? – Xan

cevap

6

Düz ve düz. İzinlere *://*/* ekleyin.

+1

Bu inanılmaz. Çalışma saatlerinden sonra, izin URL'lerinin yanlış olduğunu öğrendim: sondaki yıldız sembolü eksikti, böylece yalnızca ana sayfalarla eşleşti. Chrome'un son zaman hatası biraz yanıltıcıydı, çünkü "veri: text/html, chromewebdata" ile erişmeye çalıştığım URL'leri sansürlemişti – Anonymous

0

ArtPip önerisi bu durumda çalışırken, genellikle bir sekmede veya tüm sekmelerde bir komut dosyasını çalıştırmak ve izinleriniz bu sekmede veya sekmelerin bazılarında enjeksiyona izin vermiyorsa hatayı doğru şekilde işlemek istersiniz.

tabs.forEach(tab => { 
    chrome.tabs.executeScript(tab.id, { file: filename }, result => { 
     const lastErr = chrome.runtime.lastError; 
     if (lastErr) console.log('tab: ' + tab.id + ' lastError: ' + JSON.stringify(lastErr)); 
    }); 
}); 
İlgili konular