-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Quick fix for a script that attaches a listener to tab/window focus #108
Comments
Why are all the functions empty? |
If you're using the latest version of fx-autoconfig and you've enabled the startup hack, and it still throws an error, you can try this: function init() {
win.gBrowser.addProgressListener(tabProgressListener);
}
if (gBrowserInit.delayedStartupFinished) {
init();
} else {
let delayedListener = (subject, topic) => {
if (topic == "browser-delayed-startup-finished" && subject == window) {
Services.obs.removeObserver(delayedListener, topic);
init();
}
};
Services.obs.addObserver(
delayedListener,
"browser-delayed-startup-finished"
);
} |
That code did the trick! Re: empty functions --> I removed the code in the functions to make it easy to read, it was just to test if the eventlistener could be attached. Thanks for the help- I was at wits end, but knew it was something that should be relatively elementary. |
I wouldn't call it elementary, but it comes up a lot. The But for those scripts, it was fine and probably ideal to just delay execution until startup is finished. That's why I asked about the empty functions, since I can't say whether delaying would cause problems for your script. If you do run into issues, there are also some alternative ways to add a progress listener without reference to |
Yeah, There could be some way to make the hack work again, but to be honest I think it would be much better for script authors to delay the execution of functions that actually do depend on |
I was assuming that the win.gBrowser way of calling things was suddenly removed from the codebase after being deprecated for a while.. but that was my guess. I wasn't expecting that the win.gBrowser was needing to be delayed -- without seeing the code in the function, taking a stab in the dark that it could have been just a matter of delaying it was a good call. If you are curious, the code reintroduces being able to change the background color and text color of the urlbar based on the url scheme and connection security type. I know you can do some basic styling using only css, but this way allows more effects that closer match what Opera 8-11 had. |
You can search all the Firefox source code at https://searchfox.org - here is gBrowser for example. (refresh this, I pasted the wrong link) |
Hi aminomancer,
I was wondering if you had time to resolve something for my script which was working in Firefox 133.4 but since Firefox 134.0, I seemingly can't reference win.gBrowser anymore..
Usually when something simple like this comes up, I manage to eventually solve it, this time no luck.
Thanks for the help and time.
myprog1.txt
The text was updated successfully, but these errors were encountered: