What is the most efficient way to switch the localStorage value using a bookmarklet?

I have a switch that I would like to turn localStorage on and off in my browser using a bookmarklet.

What will be a good bookmarklet for switching the value of a hard-coded key between "0" and "1"?

+4
source share
1 answer
 javascript:(function(){localStorage["key"]=(localStorage["key"]=="1"?"0":"1")})() 

Please note that the bookmarklet should be launched while the browser is on the page in the domain to which the localStorage value that you want to switch belongs.

+2
source

Source: https://habr.com/ru/post/1401656/


All Articles