Skip to content
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

Firefox Portable #13

Open
dima6526 opened this issue Mar 11, 2022 · 9 comments
Open

Firefox Portable #13

dima6526 opened this issue Mar 11, 2022 · 9 comments

Comments

@dima6526
Copy link

Stopped working on FF Portable since some time ago, changing settings, updating FF didn't help.

@Hvalfisk
Copy link

It has stopped working for me. I am using Firefox 99.0b6

@Hvalfisk
Copy link

It works again after disabling Tampermonkey

@dima6526
Copy link
Author

Indeed, thanks for pointing it out. Hope the conflict gets resolved in future versions.

@krompus
Copy link

krompus commented Apr 1, 2022

@Hvalfisk Thanks for updating this thread with the fix; I wasn't using Tampermonkey much anyways, and now Back to Close works again. :)

@ElhemEnohpi
Copy link

ElhemEnohpi commented Oct 29, 2022

This isn't unique to Firefox Portable, it also happens on the Mac version, etc. It's been reported in the Tampermonkey issues here: Tampermonkey/tampermonkey#1566

Not working on Firefox 106 Mac, or Firefox Developer Edition 107.0b5, with TamperMonkey 4.18.0, or Beta 4.19.6171 installed, when doing "open link in a new tab". The "back" button in the new tab doesn't show any history. It still works if you open a new tab and enter a URL. Tampermonkey needs only to be installed, without any scripts active. Unchecking "Enabled" from the Tampermonkey menu doesn't help - you have to disable it completely with the addons manager. The following lines appear in the browser console when you do "open link in new tab" with Tampermonkey installed, which are not there when it isn't:

Content Security Policy: The page’s settings blocked the loading of a resource at inline (“script-src”). moz-extension:58:146
Content Security Policy: The page’s settings blocked the loading of a resource at inline (“script-src”). moz-extension:58:361

@CennoxX
Copy link

CennoxX commented Jan 27, 2024

Tampermonkey injects a history entry on its own. So this incompatibility with Tampermonkey could be fixed, by adding one to the required length where not a new tab

code: source.replace('__PUSH_STATE__', tabs[tab.id].push).replace('__REQUIRED_LENGTH__', tabs[tab.id].newtab ? 2 : 1),

making it

code: source.replace('__PUSH_STATE__', tabs[tab.id].push).replace('__REQUIRED_LENGTH__', tabs[tab.id].newtab ? 2 : 2),

on line 58 of background.js, but only if Tampermonkey version 5+ is used.

To check the installed Tampermonkey version the following code could be used, with the permission management in the manifest:

browser.management.getAll().then((addons) => {
    var tampermonkey = addons.find(i => i.id == "[email protected]" && i.name == "Tampermonkey");
    console.log("uses new tampermonkey: " + (tampermonkey != null && tampermonkey.enabled && tampermonkey.version.split(".")[0] > 4)); 
})

I don't know whether it makes sense to include a special check for this. An additional option would also be sufficient.

@ElhemEnohpi
Copy link

ElhemEnohpi commented Jan 30, 2024

@CennoxX - thanks for this! I tested it by changing the one line ending from 1 to 2 as you said, and loading the extension in the latest Firefox Developer Edition on macOS, along with Tampermonkey. It does restore the "back to close" function for tabs opened from the context menu "open link in new tab", which had been broken as I described above. Unfortunately, it's inconsistent in some cases. For example, doing "open link in new tab" with this png link does work without the modification, but with it, sometimes it functions with the back button closing it, but sometimes doesn't have an active "back" button.

Some links that automatically open in a new tab with target="_blank" are not broken by Tampermonkey without the modification, and the back to close function still works. For example, single-clicking on links in posts or comments on Reddit. With this modification, they now are broken. From a bit of testing with the W3Schools Tryit Editor, it seems to be only broken if the link is to an external site. There's also some further inconsistency, for example, links from Reddit to YouTube become broken by Tampermonkey, and remain broken with this modification.

My Javascript skills aren't good enough to fix it myself. It looks like the developer, @jsmnbom hasn't been around for a long time, and I guess may not respond. Hopefully someone else can take it on!

@CennoxX
Copy link

CennoxX commented Mar 7, 2024

@ElhemEnohpi Could you test this new fix, that should work with and without Tampermonkey?
Instead of

if (__PUSH_STATE__ && history.length === __REQUIRED_LENGTH__) {

check all times for both history.length = 1 and 2

    if (__PUSH_STATE__ && (history.length === 1 || history.length === 2)) {

This seems to work for me...

Edit:
One negative side effect seems to be, that an extra "Close Tab" history entry gets added to the history on restored tabs (compare An extra Close Tab entry gets added to the history on restored tabs #2). For the example in #2 this time it would be in the order: Close Tab -> Close Tab -> Site 1 -> Site 2 -> Site 3
... so that shouldn't be more than an aesthetic imperfection, if you take a look at your history by right clicking on the navigation arrow.

@ElhemEnohpi
Copy link

@CennoxX Unfortunately that doesn't seem to work for me at all. A tab opened with "Open Link in New Tab" has no active back button or history entry.

I'm not sure if you meant this fix to be in addition to the other one in background.js, or as a replacement. I tried it both ways, but neither works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants