Skip to content

Conversation

@kaos-55
Copy link
Contributor

@kaos-55 kaos-55 commented May 27, 2025

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

script-fix-2

kaos-55 added 4 commits May 27, 2025 11:22
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.
@kaos-55
Copy link
Contributor Author

kaos-55 commented Jul 28, 2025

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🤦‍♂️
So I fixed it and the option works again. I think now it is possible to merge the changes @aminomancer

}

togglePrivate(tab = gBrowser.selectedTab) {
tab.isToggling = true;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove this?

Copy link
Contributor Author

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.🤷‍♂️

Comment on lines +414 to +418
lazy.PlacesUtils.openTabset = function(aURIs, aOptions) {
aOptions = aOptions || {};
aOptions.userContextId = aOptions.userContextId || 0;
originalOpenTabset.call(this, aURIs, aOptions);
};
Copy link
Owner

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.

Comment on lines +64 to +65
let { SessionStoreInternal, TAB_CUSTOM_VALUES } =
ChromeUtils.importESModule("resource:///modules/sessionstore/SessionStore.sys.mjs");
Copy link
Owner

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.

Comment on lines +532 to +535
let newTab = openTrustedLinkIn(urlToOpen, "tab", {
userContextId: targetUserContextId,
index: tab._tPos + 1,
inBackground: tab != gBrowser.selectedTab,
Copy link
Owner

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.

Comment on lines +538 to +541
if (tab == gBrowser.selectedTab) {
gBrowser.selectedTab = newTab;
if (gURLBar.focused) gURLBar.focus();
}
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants