Greasy Fork is available in English.

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?

發表回覆

登入以回復