2014-08-30 80 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}为{“网址“:域,”名称“:名称,安全:真}

希望它的作品