diff --git a/src/ext/lib/video-transform/Resizer.js b/src/ext/lib/video-transform/Resizer.js index cc07cc5..5fb32a6 100644 --- a/src/ext/lib/video-transform/Resizer.js +++ b/src/ext/lib/video-transform/Resizer.js @@ -650,7 +650,8 @@ class Resizer { if (!this.userCss) { this.injectCss(newCssString); this.userCss = newCssString; - } else { + } else if (newCssString !== this.userCss) { + // we only replace css if it this.replaceCss(this.userCss, newCssString); this.userCss = newCssString; } diff --git a/src/ext/uw-bg.js b/src/ext/uw-bg.js index 85e389b..e708f9b 100644 --- a/src/ext/uw-bg.js +++ b/src/ext/uw-bg.js @@ -69,16 +69,21 @@ class UWServer { } } async removeCss(css, sender) { - if (BrowserDetect.firefox || BrowserDetect.edge) { - browser.tabs.removeCSS(sender.tab.id, {code: css, cssOrigin: 'user', frameId: sender.frameId}); - } else if (BrowserDetect.chrome) { - chrome.tabs.removeCSS(sender.tab.id, {code: css, cssOrigin: 'user', frameId: sender.frameId}); - } + try { + if (BrowserDetect.firefox || BrowserDetect.edge) { + browser.tabs.removeCSS(sender.tab.id, {code: css, cssOrigin: 'user', frameId: sender.frameId}); + } else if (BrowserDetect.chrome) { + // this doesn't work currently, but hopefully chrome will get this feature in the future + chrome.tabs.removeCSS(sender.tab.id, {code: css, cssOrigin: 'user', frameId: sender.frameId}); + } + } catch (e) { } } async replaceCss(oldCss, newCss, sender) { - this.injectCss(newCss, sender); - this.removeCss(oldCss, sender); + if (oldCss !== newCss) { + this.injectCss(newCss, sender); + this.removeCss(oldCss, sender); + } } scheduleGc(timeout) {