That's a bit of a surprise. So in short. It works when you do it manually, but it fails when TM does it. The only thing I noticed was that you ran the lines of code in the opposite order, but it really should not matter.
At least we can be glad that it's not a critical issue. It's probably one of the least needed functions.
To be honest I can't think about a solution right now. To me, it makes no sense that it works when you do it manually.
What might give more clues is to edit the script code that you actually use. Not sure how comfortable you are with that, but it can be edited through TamperMonkey. It's line 553-554 in version 1.4.8. Commenting out one by one could maybe tell us something. If it's the first line one could try to rewrite it, but then you need some JS experience.
I don't think this will matter, but in my development branch I have changed the end of 553 to:
It makes more sense to insert it before the div that it belongs to, than after a div that isn't related. But again, I can't imagine it being a fix for the issue itself.