Open basshelal opened 5 years ago
New commit as previous one didn't work on reddit since it was only viewing if the root node had any Arabic script.
Now we check to see if this node and any of its descendants has Arabic script, like the initial code did. I also added a check to see if we've already updated this node since without it you end up with infinite loops since the MutationCallback
kept seeing our change as a legitimate change that it should notify and update again etc etc.
Hopefully this will work now, I've packed the new code into an extension and will use it myself to see if there are any other bugs I may have not noticed.
Peace to you :)
New bug discovered: When the same page changes text from converted Arabic to English (or any other non Arabic) the Arabic remains over the spot where the English should have been. You can replicate this by clicking on an Arabic playlist on YouTube, then followed immediately by an English playlist, you'll see that the Arabic remains when it shouldn't. I believe this has something to do with the MutationObserver checking only for added nodes, shouldn't be too difficult to fix.
Previously, the script only applied changes after the page was loaded and never again. This is good with static pages such as articles, but fails with any dynamic pages such as YouTube and Reddit, which load more content when it is requested without refreshing the page. I believe I have fixed this but I'd like you to check, since I don't know how the chrome extensions API works, it did work however with constants for
textSize
andlineHeight
. Sorry for using TypeScript, I just find it much safer and more productive, especially coming from a Kotlin/Java background. Hope this helped and peace to you :)