Only replace CSS if the CSS changed
This commit is contained in:
parent
eeddbe9cc6
commit
13104609cd
@ -650,7 +650,8 @@ class Resizer {
|
|||||||
if (!this.userCss) {
|
if (!this.userCss) {
|
||||||
this.injectCss(newCssString);
|
this.injectCss(newCssString);
|
||||||
this.userCss = newCssString;
|
this.userCss = newCssString;
|
||||||
} else {
|
} else if (newCssString !== this.userCss) {
|
||||||
|
// we only replace css if it
|
||||||
this.replaceCss(this.userCss, newCssString);
|
this.replaceCss(this.userCss, newCssString);
|
||||||
this.userCss = newCssString;
|
this.userCss = newCssString;
|
||||||
}
|
}
|
||||||
|
@ -69,17 +69,22 @@ class UWServer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
async removeCss(css, sender) {
|
async removeCss(css, sender) {
|
||||||
|
try {
|
||||||
if (BrowserDetect.firefox || BrowserDetect.edge) {
|
if (BrowserDetect.firefox || BrowserDetect.edge) {
|
||||||
browser.tabs.removeCSS(sender.tab.id, {code: css, cssOrigin: 'user', frameId: sender.frameId});
|
browser.tabs.removeCSS(sender.tab.id, {code: css, cssOrigin: 'user', frameId: sender.frameId});
|
||||||
} else if (BrowserDetect.chrome) {
|
} 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});
|
chrome.tabs.removeCSS(sender.tab.id, {code: css, cssOrigin: 'user', frameId: sender.frameId});
|
||||||
}
|
}
|
||||||
|
} catch (e) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
async replaceCss(oldCss, newCss, sender) {
|
async replaceCss(oldCss, newCss, sender) {
|
||||||
|
if (oldCss !== newCss) {
|
||||||
this.injectCss(newCss, sender);
|
this.injectCss(newCss, sender);
|
||||||
this.removeCss(oldCss, sender);
|
this.removeCss(oldCss, sender);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
scheduleGc(timeout) {
|
scheduleGc(timeout) {
|
||||||
if (this._gctimeout) {
|
if (this._gctimeout) {
|
||||||
|
Loading…
Reference in New Issue
Block a user