Skip to content

[BUG]Again, the script stopped working due to new changes in Nightly 136a. (Old issue: The keyboard shortcut functionality and the context menu option of the Private Tabs script stopped working in Firefox Nightly). #109

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

Open
kaos-55 opened this issue Jan 12, 2025 · 19 comments · May be fixed by #115
Assignees
Labels
bug Something isn't working

Comments

@kaos-55
Copy link
Contributor

kaos-55 commented Jan 12, 2025

Link to the file containing the bug
https://github.com/aminomancer/uc.css.js/blob/master/JS/privateTabs.uc.js

Describe the bug
Some of the functionality of the Private Tabs script stopped working in Nightly 136a, specifically the shortcut Ctrl+Alt+P and the option to open a link in a new private tab in the context menu when right-clicking a link does not work either, clicking the option does nothing.

To Reproduce
Steps to reproduce the behavior:

  1. Install Firefox Nightly 136a
  2. Install privateTabs.uc.js script
  3. Press the key combination Crtl+Alt+P
  4. Right-click a link and select the option to open the link in a new private tab.

Expected behavior
Pressing Ctrl+Alt+P opens a new private tab.
Clicking the Open link in new private tab option opens a new private tab.

Desktop (please complete the following information):

  • OS: Windows 10
  • Firefox update channel: Nightly 136
  • Version: 136a1
  • Build ID: 20250112

Additional context
The script is fully functional up to Firefox version 135 beta, from nightly 136 on some features of the script start to fail, the new private tab button in the tab bar remains functional.

@kaos-55 kaos-55 added the bug Something isn't working label Jan 12, 2025
@aminomancer
Copy link
Owner

What fx-autoconfig version?

@kaos-55
Copy link
Contributor Author

kaos-55 commented Jan 13, 2025

fx-autoconfig version 0.10.4 I understand that this is the latest version

@kaos-55
Copy link
Contributor Author

kaos-55 commented Jan 14, 2025

I just found something, I do not know if it can be useful, apparently it is related to these changes:
Bug 1937080 - Block inline event handlers in Nightly https://hg.mozilla.org/integration/autoland/rev/b835e8ac47e3
Disabling this option (security.browser_xhtml_csp.enabled) makes the script functional again.

@aminomancer
Copy link
Owner

That's a useful clue, thanks. Try updating to 1.4.0 in 3f426af

@kaos-55
Copy link
Contributor Author

kaos-55 commented Jan 14, 2025

I tried version 1.4.0 and it doesn't seem to work, now even the new private tab button doesn't appear. I went back to the previous version to see if it wasn't a problem with the installation, and version 1.3.3 works 🤷‍♂️

@aminomancer
Copy link
Owner

Can you show me the browser console logs for 1.4.0? And you're still using fx-autoconfig 0.10.4?

@kaos-55
Copy link
Contributor Author

kaos-55 commented Jan 15, 2025

Sure here it is:
browser-console-firefox
fx-autoconfig is in version 0.10.4

@aminomancer
Copy link
Owner

Gotcha, I made a mistake with the hotkey registration. Give 1.4.1 a try, in 361b324.

@kaos-55
Copy link
Contributor Author

kaos-55 commented Jan 17, 2025

Yes, the new version works in nightly, again thanks for fixing it I close the issue.

@kaos-55 kaos-55 closed this as completed Jan 17, 2025
@kaos-55
Copy link
Contributor Author

kaos-55 commented Jan 25, 2025

Again, I reopen the issue. The script stopped working again due to these new changes that were implemented nightly on 01/23/2015:
https://bugzilla.mozilla.org/show_bug.cgi?id=1881888
Now the problem is due to the removal of several functions, one of which is used by the script.
Image
I don't know if it would be best to wait for the next nightly release (137) so they can finish removing everything they planned for 136 and avoid breaking scripts after a short time.

@kaos-55 kaos-55 reopened this Jan 25, 2025
@kaos-55 kaos-55 changed the title [BUG]New issue: The keyboard shortcut functionality and the context menu option of the Private Tabs script stopped working in Firefox Nightly. [BUG]Again, the script stopped working due to new changes in Nightly 136a. New issue: The keyboard shortcut functionality and the context menu option of the Private Tabs script stopped working in Firefox Nightly. Jan 25, 2025
@kaos-55 kaos-55 changed the title [BUG]Again, the script stopped working due to new changes in Nightly 136a. New issue: The keyboard shortcut functionality and the context menu option of the Private Tabs script stopped working in Firefox Nightly. [BUG]Again, the script stopped working due to new changes in Nightly 136a. (Old issue: The keyboard shortcut functionality and the context menu option of the Private Tabs script stopped working in Firefox Nightly). Jan 25, 2025
@aminomancer
Copy link
Owner

aminomancer commented Jan 29, 2025

Ah, that's a big problem. They removed JSM support, including Cu.import, which exposed all the variables. People have been using it as a hack for a long time to get access to variables that are not exported by the module. In this case, TAB_CUSTOM_VALUES and SessionStoreInternal, which gives us access to restoreTab, a method that is needed to convert a tab back and forth between the private contextual identity and no identity.

Without that, we would need to use the public duplicateTab function like the original script. I avoided that when I made the script because it doesn't let us pass the skipAnimation parameter, which caused an unsightly animation on the tab (or at least it did; those animations may no longer exist now).

I will experiment with it when I have time, but you may need to remind me. If you want, you can try replacing togglePrivate with xiaoxiaoflood's togglePrivate (except the last line, the extra arguments to gBrowser.removeTab are worth keeping) and see if you're happy with the results. I guess even if it does have some visual jank, it's better than losing the script entirely. And maybe there is a way to stop the animations with CSS. Those are things I can look into.

As for the release cycle, it makes no difference really. There is a constant influx of changes. This just happens to be a big one, but there will be others in 137.

@kaos-55
Copy link
Contributor Author

kaos-55 commented Feb 26, 2025

I will experiment with it when I have time, but you may need to remind me. If you want, you can try replacing togglePrivate with xiaoxiaoflood's togglePrivate (except the last line, the extra arguments to gBrowser.removeTab are worth keeping) and see if you're happy with the results.

Is there a solution yet?
I tried replacing the line of code described there but the script still doesn't work.
In search of a solution, I have found that some scripts and even some extensions work around this by replacing cu.import with ChromeUtils.defineESModuleGetters(this, {...});
But I have no idea how it would be implemented in the script, or if it would be the right way to do it.

@aminomancer
Copy link
Owner

No, Cu.import is fundamentally different from the modern import methods like ChromeUtils.importESModule. It is able to basically forcibly export every variable to the importer, even variables that the script does not export. Like normally, to export something, the module has to say export const myString = "hello". But with Cu.import, the module could say const myString = "hello" and I'd be able to do const {myString} = Cu.import(module). So that allowed us to hack into private stuff that the module doesn't want to export. SessionStore works as a public wrapper for SessionStoreInternal. All the actual logic is in SessionStoreInternal, and SessionStore just provides an API for using some of that logic.

If you look through the code carefully, you'll see that when you switch a tab between private and non-private, the script is actually saving the tab state, duplicating the tab, inserting the tab state into the duplicate, then deleting the original tab. All that happens very quickly.

I'm not sure what the situation is with tab animations right now. When I made the script, I had tab animations that caused problems for this process. It's supposed to look like the tab is just becoming private or non-private, but in reality we're replacing the tab with a duplicate of itself. Tab animations make it apparent that this is what we're doing, because the duplicate comes in with an animation. So it ends up looking janky. This is why I could not just use the public SessionStore.duplicateTab method, I had to make my own custom version of it that disabled tab animations. And to make a custom version of it requires access to SessionStoreInternal, because the method references stuff in SSI.

But tab animations have been stripped down considerably, so that may no longer be a problem. In which case, you could possibly just use SessionStore.duplicateTab and it'd be fine. I don't have time to test it though.

So the point is, there is no replacement for Cu.import. It allowed us to hack into stuff like SessionStoreInternal. This is no longer possible, there's no way to do it without a custom Firefox build. But it's possible you don't need to hack into SSI anymore. In that case, you'd do what I described in my previous post, not trying to replace Cu.import but just getting rid of the whole restoreTab thing and using SessionStore.duplicateTab the way xiaoxiaoflood's script does.

@kaos-55
Copy link
Contributor Author

kaos-55 commented Feb 28, 2025

Thanks for the explanation. Damn, that means that the script is “dead”?
I also tried the xiaoxiaoflood script and it is also broken and it seems that the author of the script is not going to fix it at some point (it has been 2 years without updating the scripts).

@aminomancer
Copy link
Owner

The script can still work, it's like I said, it needs to be using SessionStore.duplicateTab instead of my custom duplicateTab method. That may or may not cause visual jank, depending on the CSS transitions for tabs. I will see if I can fix it for you

@aminomancer
Copy link
Owner

And xiaoxiaoflood's script is broken in a different way than mine is. His is using the original duplicateTab method. But it's also using Cu.import for some other things, which is unnecessary. Like it's using it to check if TST is installed, but my script already has a different way of doing that, which still works. Same with checking if the private tab button already exists. So my script already mostly works, all you need to do is take his duplicateTab and togglePrivate and put it into my script and get rid of the Cu.import stuff. The only potential problem is that might cause weird animations in the tab when toggling a tab, depending on the CSS. That was the reason I did it the way I did, hacking the SessionStore methods, but my approach no longer works.

@kaos-55
Copy link
Contributor Author

kaos-55 commented Mar 4, 2025

So I have no choice but to wait until the script works again with new versions of Firefox.😔

@aminomancer
Copy link
Owner

New versions of Firefox aren't gonna make the script work. The script needs to be edited in the way I said

@kaos-55
Copy link
Contributor Author

kaos-55 commented Mar 5, 2025

Sorry I think I explained myself wrong, I meant waiting for the script to be fixed so that it works again with the new versions of Firefox.

@kaos-55 kaos-55 linked a pull request May 27, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants