-
Notifications
You must be signed in to change notification settings - Fork 26
Update privateTabs.uc.js fix for Firefox Nightly 141 #115
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
base: master
Are you sure you want to change the base?
Conversation
Firefox Nightly 141 (31-05-2025) broke the previously updated privatetabs.uc.js script. So I am removing the previous fix in favor of the new fix.
Fix the context menu option to convert a normal tab to private by right-clicking on the tab.
|
After two months, I realized that the option to convert a normal tab into a private tab using the context menu by right-clicking on a tab was not working🤦♂️ |
| } | ||
|
|
||
| togglePrivate(tab = gBrowser.selectedTab) { | ||
| tab.isToggling = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why remove this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was the only way I found to get the script working again😅
I think that the removed part of the code is what makes it possible to change a normal tab to a private one, and that feature is still functional with the changes made despite that part of the code being removed.
I don't understand why it would be wrong to remove that part of the code if the script is functional. I think that's better than having a broken script.🤷♂️
| lazy.PlacesUtils.openTabset = function(aURIs, aOptions) { | ||
| aOptions = aOptions || {}; | ||
| aOptions.userContextId = aOptions.userContextId || 0; | ||
| originalOpenTabset.call(this, aURIs, aOptions); | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's PlacesUIUtils, not PlacesUtils. there is no PlacesUtils.openTabset, it doesn't exist. so this is doing nothing. therefore, opening multiple private tabs is not working.
also, eval is better. it means if minor changes are made to the function, they get forwarded to your modified version.
as far as I can tell, there's no reason the original version on the left wouldn't work. unless you have eval blocked because you don't have security.allow_unsafe_dangerous_privileged_evil_eval set to true.
| let { SessionStoreInternal, TAB_CUSTOM_VALUES } = | ||
| ChromeUtils.importESModule("resource:///modules/sessionstore/SessionStore.sys.mjs"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't work. Neither of these properties are exported, they're hidden in the code and not available to outside callers, so they can't be imported by importESModule. Like I said in the other thread, you'd need to change the duplicateTab code so it uses SessionStore.duplicateTab, like xiaoxiaoflood's version. Then your code doesn't rely on SessionStoreInternal or TAB_CUSTOM_VALUES. But that has trade-offs.
| let newTab = openTrustedLinkIn(urlToOpen, "tab", { | ||
| userContextId: targetUserContextId, | ||
| index: tab._tPos + 1, | ||
| inBackground: tab != gBrowser.selectedTab, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't restore the tab state. You'll lose tab history. You should be using SessionStore.duplicateTab, like in xiaoxiaoflood's version.
| if (tab == gBrowser.selectedTab) { | ||
| gBrowser.selectedTab = newTab; | ||
| if (gURLBar.focused) gURLBar.focus(); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should save this before you open/duplicate the tab. Like at line 531. wasSelected = tab === gBrowser.selectedTab. Then check wasSelected here. Because tab selection changes after opening the new tab.
This pull request fixes the privateTabs.uc.js script in Firefox nightly 141, it also fixes the problem of the script being blocked by the content-security-policy in Firefox nightly 141.
Closes #109