Skip to content

Instantly share code, notes, and snippets.

@utilmind
Last active April 20, 2021 22:23
Show Gist options
  • Save utilmind/9ff00a1bfa6de0c1f68b2c2bd0672302 to your computer and use it in GitHub Desktop.
Save utilmind/9ff00a1bfa6de0c1f68b2c2bd0672302 to your computer and use it in GitHub Desktop.
Replacement for regular localStorage or sessionStorage objects, if they blocked by some paranoiac browser, like Brave with default settings
// This is replacement for regular localStorage or sessionStorage objects,
// if they blocked by some paranoiac browser, like Brave with default settings....
var expireStorage = {
length: function() {
return data.length;
},
key: function(key) {
return Object.keys(data)[key];
},
getItem: function(key) {
return data[key];
},
setItem: function(key, val) {
data[key] = val;
},
removeItem: function(key) {
delete data[key];
},
clear: function() {
data = {};
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment