Thank you @justin
Updated to the code below and it is working again.
<script>
document.addEventListener('DOMContentLoaded', function(){
if(document.querySelector(".topic-category a[href*='/c/german']")){
document.documentElement.lang = "de";
}
});
</script>