Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to programatically remove all local storage from chrome extension of a specified domain

I would like to with my chrome extension remove all localStorage of a specified domain

when I open the google chrome , I can remove it by going to settings -> All cookies and then find the local storage by the domain name, and delete it manually.

Here is what I get:

server.myserver.test.com

Local Storage

Source: https://server.myserver.test.com
Disk Size:  5,0 KB
Last modification:  Saturday...

What would I need to do to do this inside my chrome extension, assuming that I have permission for the specified servers to access its cookies.

Thank you!

like image 243
Grego Avatar asked Jun 08 '12 16:06

Grego


People also ask

How do I remove local storage from another domain?

If you want to modify or clear the data in localStorage for a specific domain, then just insert a content script in the page that invokes localStorage. clear() . Save this answer.

Where are my Chrome extensions local storage?

With the extension's background page open, just go to the developer tools by pressing F12, then go to the Application tab. In the Storage section expand Local Storage. After that, you'll see all your browser's local storage there.

How do I get rid of local storage?

removeItem() : How to delete localStorage sessions To delete local storage sessions, use the removeItem() method. When passed a key name, the removeItem() method removes that key from the storage if it exists. If there is no item associated with the given key, this method will do nothing.


2 Answers

I think you can run content script for that specific Domain and remove local storage data by calling:

localStorage.clear();

Chrome Cookies API removes only cookies.

like image 74
saroyanm Avatar answered Oct 19 '22 01:10

saroyanm


to used below function

 chrome.storage.local.clear()
like image 21
Vijay Kumbhani Avatar answered Oct 19 '22 01:10

Vijay Kumbhani