Hello!
I am a developer for an open-source project called ListenBrainz (https://github.com/metabrainz/listenbrainz-server).
We have recently seen some strange errors accumulating in our error reporting software, with "/userscript.html?name=User-Details-on-Hover.user.js" showing as the source.
After some searching I found this userscript to be the source of the error.
If I understand correctly this userscript is meant to be used in conjunction with Lemmy, and the first thing the script does is check whether it should apply to the current page.
However, the check in question throws an error which is then reported by our reporting software.
Running the unmodified const isLemmy = document.head.querySelector("[name~=Description][content]").content === "Lemmy"; on a random page causes Uncaught TypeError: Cannot read properties of null (reading 'content').
However, using the optional chaining ?. before trying to access .content ensures the code doesn't throw an error:
Hello! I am a developer for an open-source project called ListenBrainz (https://github.com/metabrainz/listenbrainz-server). We have recently seen some strange errors accumulating in our error reporting software, with "/userscript.html?name=User-Details-on-Hover.user.js" showing as the source.
After some searching I found this userscript to be the source of the error. If I understand correctly this userscript is meant to be used in conjunction with Lemmy, and the first thing the script does is check whether it should apply to the current page. However, the check in question throws an error which is then reported by our reporting software.
Running the unmodified
const isLemmy = document.head.querySelector("[name~=Description][content]").content === "Lemmy";
on a random page causesUncaught TypeError: Cannot read properties of null (reading 'content')
.However, using the optional chaining
?.
before trying to access.content
ensures the code doesn't throw an error:Alternatively, if the optional chaining operator is too recent a feature, the boolean can be broken down like so: