Google翻译 Chrome强制夜间模式视觉修复

删除Google翻译的一个元素 使强制进入夜间模式功能开启后视觉效果更佳

< 脚本Google翻译 Chrome强制夜间模式视觉修复的反馈

提问/评论

§
发表于:2020-05-19
编辑于:2020-05-19

Please, use live collections correctly

I see deletion repeating by same classname. And it is not working properly, right?:) document.getElementsByClassName function returns HTMLCollection. By the MDN " An HTMLCollection in the HTML DOM is live and it is automatically updated when the underlying document is changed". When you delete the 1st element of a live collection, the 2nd element becomes the 1st. So, all you need to do is simply delete the first element while it is in the collection, Or remove them upside down. Like this: (function (ca) { //remove by classes array     var c, el;     while (c=ca.shift()) {         el=document.getElementsByClassName( c ); // el is live collection!         while (el[0]) // or upside down for(var i=el.length-1; i>-1; i--)...             el[0].parentNode.removeChild(el[0]); // or el[0].remove()     } })( ["ls-right-arrow", "sugg-fade"] );

来啦作者
§
发表于:2020-07-22

Yes, I am a JavaScript novice, this is just a rough work made temporarily. If you have a better solution, can you post the modified complete code? thank!

来啦作者
§
发表于:2020-07-22

Now it's modified. is this correct?

发表回复

登录以发表回复。