清单摘录:
"permissions": [
"tabs",
"cookies",
"*://*/*"
]
我在 Popup.js 上尝试过的代码(没有用):
function getCookie(name) {
var dc = document.cookie;
var prefix = name + "=";
var begin = dc.indexOf("; " + prefix);
if (begin == -1) {
begin = dc.indexOf(prefix);
if (begin != 0) return null;
}
else
{
begin += 2;
var end = document.cookie.indexOf(";", begin);
if (end == -1) {
end = dc.length;
}
}
return unescape(dc.substring(begin + prefix.length, end));
}
function doSomething() {
var myCookie = getCookie("TestCookie");
if (myCookie == null) {
document.write("<p>unable to load</p>");
throw "stop execution";
}
else {
document.write("<p>loaded</p>");
// do cookie exists stuff
}
}
我收集到 chrome 扩展不支持完整的 java,但我不确定。我该如何处理这种情况?