4
A
回答
4
这是饼干样本实现,这样,你可以设置Cookie
的manifest.json
{
"name" : "Cookie API Demo",
"version" : "1",
"description" : "This is demonstration of Cookie API",
"permissions": [ "cookies","<all_urls>"],
"browser_action": {
"default_icon": "screen.png",
"default_popup":"popup.html"
},
"manifest_version": 2
}
popup.js
function cookieinfo(){
/*chrome.cookies.getAll({},function (cookie){
console.log(cookie.length);
for(i=0;i<cookie.length;i++){
console.log(JSON.stringify(cookie[i]));
}
});
chrome.cookies.getAllCookieStores(function (cookiestores){
for(i=0;i<cookiestores.length;i++){
console.log(JSON.stringify(cookiestores[i]));
}
});*/
chrome.cookies.set({"name":"Sample1","url":"http://developer.chrome.com/extensions/cookies.html","value":"Dummy Data"},function (cookie){
console.log(JSON.stringify(cookie));
console.log(chrome.extension.lastError);
console.log(chrome.runtime.lastError);
});
/*chrome.cookies.onChanged.addListener(function (changeInfo){
console.log(JSON.stringify(changeInfo));
});*/
}
window.onload=cookieinfo;
popup.html
<html>
<head>
<script src="popup.js"></script>
</head>
<body>
</body>
</html>
相关问题
- 1. 如何更改Google Chrome扩展程序中的区域设置?
- 2. chrome扩展为使用chrome.cookies.set的localhost域设置cookie API
- 3. 从Google Chrome扩展程序管理Cookie
- 4. 无法使用Chrome扩展程序设置Cookie
- 5. Google Chrome扩展程序跨域XMLHttpRequest
- 6. 如何存储Google Chrome扩展程序的偏好设置?
- 7. Chrome扩展程序API操纵其他已安装的Chrome扩展程序?
- 8. 如何为Chrome扩展程序设置App Engine后端?
- 9. Chrome扩展程序设置页面
- 10. 访问Chrome扩展程序中的Cookie
- 11. 删除Chrome扩展程序中的Cookie
- 12. 从Chrome扩展程序访问cookie
- 13. Chrome扩展程序如何基本上卷曲其他页面?
- 14. 您如何在Google Chrome扩展程序中使用Facebook Graph API?
- 15. 如何使用Google Chrome扩展程序获取链接(URL)
- 16. 如何使用Google Cast Chrome扩展程序投射HTML页面?
- 17. 如何从Chrome扩展程序使用Google Enpoints
- 18. 如何在Selenium上使用Google Chrome扩展程序?
- 19. 如何在Google Chrome扩展程序中使用HTML5的localStorage?
- 20. 在Google Chrome扩展程序manifest.json中启用跨网域权限
- 21. Chrome扩展程序/应用程序设置Javascript
- 22. 跨域jQuery.Ajax请求 - Chrome扩展程序
- 23. Chrome扩展程序:有扩展程序编辑其web_accessible_resources
- 24. 使用其他应用程序扩展Google搜索应用程序结果
- 25. Chrome扩展程序
- 26. 如何使用CookieOptions(较早的CookieOptionsArgs)为其他/父域设置cookie来设置Cookie对象?
- 27. Chrome扩展 - 扩展对设置页
- 28. Chrome扩展程序androidpublisher packageName
- 29. Chrome扩展程序
- 30. Google Chrome扩展程序Http请求
只是好奇,但你为什么要这么做? – tjameson
这对我来说会比较容易,而不是一直打开设置。 – ArrayMaster