varsa benChrome uzantıları API çerez
if (hostName == "google.com") {
chrome.runtime.sendMessage({greeting: "hello"}, function(response) {
console.log(response.farewell);
if (response.farewell == null) {console.log("cookie is null");}
});
}
background.js
function getCookies(domain, name, callback) {
chrome.cookies.get({"url": domain, "name": name}, function(cookie) {
if(callback) {
callback(cookie.value);
}
});
}
chrome.runtime.onMessage.addListener(function(message, sender, sendResponse) {
if (message.greeting == "hello") {
getCookies("http://www.google.com", "cookie_name", function(id) {
if (id) {
alert("cookie "+id);
sendResponse({farewell: id});
} else {
alert("cookie "+id);
sendResponse({farewell: id});
}
});
return true;
}
});
content.js kodu aşağıdaki ile krom uzantılı çerez kontrol etmeye çalışıyorum kontrol etmez Çerez ayarlanmışsa bu kod çalışır. Ancak çerez yoksa uyarı ve yanıt yoktur. Çerez olup olmadığını nasıl kontrol ederim? Neyi yanlış yapıyorum?