2014-08-30 75 views
0

在我的代碼中,我希望使用來自發布到(meepcity.com)的網站的cookie發佈到兩個php文件。然而,在加載Chrome擴展,我收到以下兩個錯誤:檢索網站的cookie併發布到網站時的擴展錯誤?

Error in response to cookies.get: TypeError: Cannot read property 'value' of undefined at token

除了

Unchecked runtime.lastError while running cookies.get: No host permissions for cookies at url: "http://www.meepcity/". at token

我看不出有什麼毛病我的代碼,但我承擔問題與cookie的檢索有關。我已經包含了我的代碼以及下面的清單。謝謝!

function token(domain, name, callback) { 
    chrome.cookies.get({"url": domain, "name": name}, function(cookie) { 
     if(callback) { 
      callback(cookie.value); 
     } 
    }); 
} 
token("http://www.meepcity", "PHPSESSID", function(secureToken) { 
    function buy(id, security) { 
     $.ajax({url:"http://api.meepcity.com/prepareAssetPurchase.php",type:"POST",data:{sess:security,aId:id,sId:0}}) 
     $.ajax({url:"https://api.meepcity.com/finishAssetPurchase.php",type:"POST",data:{sess:security}}).done(function() { console.info("Successfully purchased!"); }); 
} 
    buy(44,secureToken); 
}); 

清單

{ 
    "background": { 
     "scripts": [ "jquery.js", "background.js" ] 
    }, 
    "content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'", 
    "description": "Meepcity", 
    "homepage_url": "http://www.meepcity.com/", 
    "incognito": "split", 
    "manifest_version": 2, 
    "name": "Meepcity", 
    "permissions": [ "unlimitedStorage", "tabs", "notifications", "tabCapture", "*://*.meepcity.com/*", "https://*.meepcity.com/*", "cookies", "background" ], 
    "short_name": "Meepcity", 
    "update_url": "https://clients2.google.com/service/update2/crx", 
    "version": "1.0.1", 
    "web_accessible_resources": [ "*://*.meepcity.com/*", "https://*.meepcity.com/*" ] 
} 

謝謝,我很感激。

回答

1

不知道,但我想你應該這樣做:

  1. 更改 「http://www.meepcity」 到 「https://www.meepcity.com
  2. 更改{ 「URL」:域名, 「名」:name}爲{「網址「:域,」名稱「:名稱,安全:真}

希望它的作品