Skip to content

Instantly share code, notes, and snippets.

@gx0r
Created May 17, 2019 20:14
Show Gist options
  • Save gx0r/4f8cb9f500a06dd6b07ee9253a851f3b to your computer and use it in GitHub Desktop.
Save gx0r/4f8cb9f500a06dd6b07ee9253a851f3b to your computer and use it in GitHub Desktop.
Cookie Size Meter
// Cookie size meter
(function () {
var div = document.createElement('div');
div.style.position = 'absolute';
div.style.top = '10px';
div.style.left = '10px';
div.style.border = '1px dashed black';
div.style.cursor = 'crosshair';
div.style.padding = '2px';
div.style.zIndex = 10000;
div.style.backgroundColor = 'white';
div.style.fontFamily = '"Source Sans Pro", Helvetica, sans-serif';
div.style.fontSize = '13px';
if (div.parentNode !== document.body) {
document.body.appendChild(div);
}
div.addEventListener('click', function () {
div.innerText = Math.trunc(document.cookie.length / (1024*4) * 100) + '% cookie usage'
});
div.click();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment