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

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

< Rückmeldungen aufGoogle翻译 Chrome强制夜间模式视觉修复

Frage/Kommentar

§
Veröffentlicht: 19.05.2020
Bearbeitet: 19.05.2020

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"] );

来啦Verfasser
§
Veröffentlicht: 22.07.2020

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!

来啦Verfasser
§
Veröffentlicht: 22.07.2020

Now it's modified. is this correct?

Antwort schreiben

Anmelden um eine Antwort zu senden.