xiaoxiaoflood / firefox-scripts

userChromeJS / autoconfig.js and extensions
Mozilla Public License 2.0
954 stars 83 forks source link

Why this simple uc.js don't work? #143

Closed 0rt closed 2 years ago

0rt commented 2 years ago

document.getElementById("history-panelmenu").addEventListener("click",function(e){ if(e.button == 2){ e.stopPropagation(); e.preventDefault(); undoCloseTab(0); } },false)

I am using Firefox 101, and this script used to work with alice0775's userchrome.js. And I see it is loaded in rebuild userchrome.

The script itself is simple, right click on the history-panelmenu button will restored last closed tab.

xiaoxiaoflood commented 2 years ago

Haven't tested it, but probably because my userChromeJS runs earlier, before the element history-panelmenu to exist. So in order to fix it you need to wrap the code in a DOMContentLoaded or load listener.

But please, note that this type of question is suited to Discussions and not here, so closing this.