2013-04-12 54 views
0

感謝您花時間閱讀本文。 這是我的擴展文件夾的目錄。Chrome擴展程序無法正常工作(出現權限錯誤?)

這裏是清單代碼:

{ 
    "manifest_version": 2, 
    "name": "Technobuffalo Stories", 
    "description": "Your Description about Extension goes here", 
    "version": "1.0", 
    "content_scripts": [ { 
     "js": [ "popup.js" ], 
     "matches": [ "http://feeds.feedburner.com/*" ] 
    } ], 
    "permissions": [ "http://feeds.feedburner.com/*" ], 
    "browser_action": { 
    "default_icon": "icon_16.jpeg", 
    "default_popup": "popup.html" 
    } 
} 

這裏是popup.html:

<html> 
<head> 
    <title>Technobuffalo Stories 
    </title> 
    <script type="text/javascript" src="https://www.google.com/jsapi"></script> 
    <script src="popup.js"></script> 
</head> 
<body> 
    <div id="feed" style="background-color:orange;height:500px;width:500px;" ></div> 
</body> 
</html> 

和最後都在這裏被popup.js:

的google.load(」飼料「,」1「);

function initialize() { 
    var feed = new google.feeds.Feed("http://feeds.feedburner.com/technobuffalo/rss?format=xml"); 
    feed.load(function(result) { 
    if (!result.error) { 
     var container = document.getElementById("feed"); 
     for (var i = 0; i < result.feed.entries.length; i++) { 
     var entry = result.feed.entries[i]; 
     var div = document.createElement("div"); 
     div.appendChild(document.createTextNode(entry.title)); 
     container.appendChild(div); 
     } 
    } 
    }); 
} 
google.setOnLoadCallback(initialize); 

當我打開popup.html文件,因爲它是,顯示所需的結果,但是當我加載瀏覽器擴展,只有div的背景顏色可以看出。我設置的權限是否存在任何問題,或者是否有其他問題?

謝謝, Yash。

+0

https://developer.chrome.com/extensions/contentSecurityPolicy.html –

回答

1

你必須添加下面一行到的manifest.json到能夠使用的資源從www.google.com

"content_security_policy": "script-src 'self' https://www.google.com; object-src 'self'" 

正如羅布W¯¯已經指出,這是一項安全功能已與清單版本2引入。

+0

非常感謝您花時間回答我的問題! –

相關問題