Your periodic 'leave feedback' thingie popped up, so here I am...
Using MS 4.1.1.0 in Opera (opera-dev, some back-rev version since my OS is too old to load the most recent binaries; but I am sure this is not relevant).
I turn on the 'Collect errors' setting on all extensions. This accumulates errors emitted by the extension across all tabs and the entire browser uptime (as long as the error log isn't reset). MS is particularly noisy, for instance, the current run has collected 76 uncaught reference errors. I scrolled through these and recorded where:
3x Uncaught TypeError: Cannot read properties of undefined (reading 'removeRule')
26x Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'removeRule')
modern_scroll.js:707
ms_shadow.styleSheets[0].removeRule(ms_shadow.styleSheets[0].cssRules.length-2);
22x Uncaught TypeError: Cannot read properties of undefined (reading 'onChanged')
modern_scroll.js:170
chrome.storage.onChanged.removeListener(update_prefs);
22x Uncaught (in promise) TypeError: Cannot read properties of null (reading 'style')
modern_scroll.js:576
document.getElementById("modern_scroll").style.display = null;
modern_scroll.js:996
ms_shadow.getElementById("ms_"+whichone+"bar_bg").style.transition = "opacity 0s 0s";
3x Uncaught TypeError: Cannot read properties of null (reading 'style')
modern_scroll.js:437
ms_shadow.getElementById("ms_hbar_ui").style.height = null;
modern_scroll.js:1008
ms_shadow.getElementById("ms_"+whichone+"bar_bg").style.transition = ms_shadow.getElementById("ms_"+whichone+"bar").style.transition = null;
Of these, obviously the various errors depending on getElementById()
indicate that element didn't exist at that moment; these are likely due to actions being done right as a tab is being created or (more likely) destroyed. Though that's only a guess.
The ms_shadow.styleSheets[0].removeRule
failures must indicate that ms_shadow
itself exists and has an array .styleSheets[]
, or it would have errored on that symbol. So I guess the element exists but at the moment this code is hit, doesn't have any stylesheets attached?
And finally, the chrome.storage.onChanged.removeListener()
failure seems particularly odd -- it seems that a chrome
object exists, but doesn't have a .storage
property. Yet we know that it normally does, or the entire extension would be dead in the water...
In any case, all of these are easily handled with optional chaining; which you are quite free to use now that you've set the minimum Chrome version to 100:
modern_scroll.js:707
ms_shadow.styleSheets[0]?.removeRule(ms_shadow.styleSheets[0].cssRules.length-2);
modern_scroll.js:170
chrome.storage?.onChanged.removeListener(update_prefs);
modern_scroll.js:576
document.getElementById("modern_scroll")?.style.display = null;
modern_scroll.js:996
ms_shadow.getElementById("ms_"+whichone+"bar_bg")?.style.transition = "opacity 0s 0s";
modern_scroll.js:437
ms_shadow.getElementById("ms_hbar_ui")?.style.height = null;
modern_scroll.js:1008
ms_shadow.getElementById("ms_"+whichone+"bar_bg")?.style.transition = ms_shadow.getElementById("ms_"+whichone+"bar").style.transition = null;
However, of course, these will not be the only instances, since each 'fix' lets execution now proceed to subsequent statements which would also have failed, e.g.:
modern_scroll.js:438
ms_shadow.getElementById("ms_hbar_bg_ui").style.height = null;
... was also probably about to fail. So perhaps (at least for the getEl calls) a utility function might be better:
const getElById = (doc, id) =>
(doc?.getElementById && doc.getElementById(id)) || { style: {} };
...
getElById(ms_shadow, "ms_hbar_bg_ui").style.height = null;
That is, return either successful getElementById() result, or an ephemeral stub object with a style
property so that code like getElById(ms_shadow, 'something').style.transition = 'foo';
runs happily.
Or maybe a 'setStyle' util would be better:
const setElStyleById = (doc, id, style, value) =>
(((doc?.getElementById && doc.getElementById(id)) || { style: {} }).style[style] = value);
...
setElStyleById(ms_shadow, "ms_hbar_bg_ui", "height", null);
... In any case, however you want to solve it, please reduce error output to the point where it might indicate actual errors rather than merely unhappy timing glitches during extraordinary timing events like tab closure.