4

カスタム Rss フィードを表示したい chrome アプリケーションを開発しようとしていますが、フィードが読み込まれず、上記のようなエラーが表示されます。

が表示されるエラー詳細

Refused to load the script
 'https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js'
 because it violates the following Content Security Policy directive:
 "script-src 'self'
 https://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js".

     Refused to execute inline script because it violates the following Content Security Policy directive: "script-src 'self'
 https://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js". 
 jquery.min.js:35

     Refused to load the script 'https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js'
 because it violates the following Content Security Policy directive:
 "script-src 'self'
 https://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js".

     Refused to load the script 'http://ajax.googleapis.com/ajax/services/feed/load?v=1.0&num=2&output=json&q=http%3A%2F%2Fblog.tax2290.com%2Ffeed%2F&hl=en&callback=jsonp1373953012503'
 because it violates the following Content Security Policy directive:
 "script-src 'self'
 https://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js".

マニフェスト.json

{
      "name": "Tax New 2290",
      "manifest_version": 2,
      "version": "1.1",
      "description": "Tax 2290",
    "web_accessible_resources": ["images/logo.png"],
      "icons": {
        "16": "icon16.png",
        "19":"icon19.png",
        "48": "icon48.png",
        "128": "icon128.png",
        "256": "icon256.png"
    },
     "browser_action":
    {
    "default_icon":"images/logo.png",
    "default_popup":"index.html"
    },

         "permissions": ["tabs", "<all_urls>","http://www.tax2290.com","http://*/*", "https://*/*","http://*.google.com/"],
        "content_security_policy": "script-src 'self' https://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js; https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js; object-src 'self'"

    }

index.html

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="images/feed.js"></script>
<link rel="stylesheet" href="images/style.css" type="text/css"  />
<title>Chrome Popup</title>
</head>

feed.js

        $(function() {
                var $items = $('#vtab>ul>li');
                $items.mouseover(function() {
                    $items.removeClass('selected');
                    $(this).addClass('selected');

                    var index = $items.index($(this));
                    $('#vtab>div').hide().eq(index).show();
                }).eq(0).mouseover();
            });


    $(document).ready(function () {  
       $('#divRss2').FeedEk({
            FeedUrl: 'http://blog.tax2290.com/feed/',
            MaxCount: 2,ShowDesc: true,
            ShowPubDate: true,
            DescCharacterLimit: 250
        });
    });


   > Please tel me how could avoid these errors and load the custom RSS feeds.
4

3 に答える 3

2

「content_security_policy」にはいくつかの問題があります。

1) 1 つ目は、1.4.1 と 1.9.1 の jquery 宣言の間のセミコロンを削除する必要があることです。複数の URL は、スペース 1 つだけで区切り、その他の文字は使用しないでください。

2) 2 つ目は、このスクリプトを読み込もうとしているということです。.com%2Ffeed%2F&hl=en&callback=jsonp1373953012503 "しかし、CSP でそれを許可することはありません。

3) そして 3 番目に、インライン スクリプトを許可する必要があるようです。

「content_security_policy」を次のように変更します。

"content_security_policy": "script-src 'self' https://ajax.googleapis.com/ 'unsafe-inline'; object-src 'self'"

「unsafe-inline」は、「インライン スクリプトの実行を拒否されました」というエラーを修正する必要があります。

https://ajax.googleapis.com/では、両方のバージョンの jquery と /ajarx/services/feed/load URL をロードできるようにする必要があります。

于 2016-01-18T18:25:23.700 に答える
1

パッケージ化されたアプリをビルドする場合、外部スクリプトを読み込むことはできません。アプリケーションには、すべてのスクリプト、スタイル、または画像を埋め込む必要があります。

このリンクをチェックして、Chrome アプリの CSP ルールに従っていることを確認してください: https://developer.chrome.com/extensions/contentSecurityPolicy

于 2013-07-18T19:53:36.977 に答える