From 8a70c1719de3e5a8f7297ee95ace99ce0832cb41 Mon Sep 17 00:00:00 2001 From: Rasz_pl Date: Wed, 10 Apr 2024 21:35:41 +0200 Subject: [PATCH] Update core.js limit localstorage writes to only essential ones currently we are writing on every page load, and its my fault :( --- js&css/web-accessible/core.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/js&css/web-accessible/core.js b/js&css/web-accessible/core.js index 290e92db2..631d436a0 100644 --- a/js&css/web-accessible/core.js +++ b/js&css/web-accessible/core.js @@ -155,15 +155,20 @@ document.addEventListener('it-message-from-extension', function () { ImprovedTube.storage = message.storage; if (ImprovedTube.storage.block_vp9 || ImprovedTube.storage.block_av1 || ImprovedTube.storage.block_h264) { - let atlas = {block_vp9:'vp9|vp09', block_h264:'avc1', block_av1:'av01'} - localStorage['it-codec'] = Object.keys(atlas).reduce(function (all, key) { + let atlas = {block_vp9:'vp9|vp09', block_h264:'avc1', block_av1:'av01'}, + codec = Object.keys(atlas).reduce(function (all, key) { return ImprovedTube.storage[key] ? ((all?all+'|':'') + atlas[key]) : all}, ''); - } else { + if (localStorage['it-codec'] != codec) { + localStorage['it-codec'] = codec; + } + } else if (localStorage['it-codec']) { localStorage.removeItem('it-codec'); } if (ImprovedTube.storage.player_60fps === false) { - localStorage['it-player30fps'] = true; - } else { + if (!localStorage['it-player30fps']) { + localStorage['it-player30fps'] = true; + } + } else if (localStorage['it-player30fps']) { localStorage.removeItem('it-player30fps'); }