N
N
Nickname123122016-11-29 09:56:41
JavaScript
Nickname12312, 2016-11-29 09:56:41

Chrome extension how to delete the right cookie?

Good day!
I'm writing extensions for chrome, I want to delete an HTTP cookie on a certain site after it is loaded
"permissions": [
"storage",
"cookies",
"tabs",
" http://*/* ",
" https://*/ * "
]
"background": {
"scripts": ["background.js"]
}
Permissions and background connected, what to do next?
I tried through https://developer.chrome.com/extensions/cookies , but it didn't work for me
Who will help out? I will be grateful!

chrome.tabs.onActivated.addListener(function(activeInfo) {
   chrome.tabs.get(activeInfo.tabId, function(Tab) {
     if (Tab.url.indexOf("https://www.site.ru/") != -1){
      chrome.cookies.getAll({domain: "www.site.ru"}, function(cookies) {
        for(var i=0; i<cookies.length;i++) {
          alert(cookies[i].name);
          if (cookies[i].name == "city")
            chrome.cookies.remove({url: "www.site.ru" + cookies[i].path, name: cookies[i].name});
        }
      });
     }
   });
});

if (cookies[i].name == "city") - this block is executed, that is, the script finds cookies with that name, but when it comes to deleting it, for some reason it does not delete it
Cookies that I want to delete are HTTP-type
Any idea how to finally delete this cookie?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
cSharpDevelopers, 2020-07-12
@cSharpDevelopers

figured it out? and then I encountered)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question