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

Not working on Firefox 133 #17

Open
akgis32 opened this issue Nov 6, 2024 · 13 comments
Open

Not working on Firefox 133 #17

akgis32 opened this issue Nov 6, 2024 · 13 comments

Comments

@akgis32
Copy link

akgis32 commented Nov 6, 2024

I been looking for this kinda of option and found this addon but doesnt work in 133 it seems.

I open a new tab but using the back button at the end of history doesnt closes it

@CennoxX
Copy link

CennoxX commented Nov 6, 2024

@akgis32 Do you have Tampermonkey installed?

@m3enzo
Copy link

m3enzo commented Dec 8, 2024

I'm seeing the same issue. Going back does not close the tab and I am not using Tampermonkey.

@finnmerlett
Copy link

For me the back button is just greyed out and I don't see the inserted item in the history list at all

@Hvalfisk
Copy link

It stopped working, I'm currently on FF v135, I have Violentmonkey installed

@CennoxX
Copy link

CennoxX commented Jan 24, 2025

Here is a minimal userscript, that adds a fake history entry on new tabs and auto-closes the tab when navigating back to it. Tested with Tampermonkey. In Firefox you have to set dom.allow_scripts_to_close_windows to true in about:config.

Edit: since Firefox 135 this only works if the page was activated before :/

(function () {
    "use strict";
    var events = ["click", "contextmenu", "keydown", "dragstart"];
    events.forEach(e => document.addEventListener(e, ()=>{
        if (history.length === 1 && !sessionStorage.getItem("__close")) {
            sessionStorage.setItem("__close", 1);
            history.replaceState({ close: 1 }, "", location.href);
            history.pushState(null, "", location.href);
        }
    }));
    addEventListener("popstate", (e) => e.state?.close && close());
})();

@ChaosDMNS
Copy link

What happened? doesn't work any more.

@ChaosDMNS
Copy link

Tried the script fix.. Didn't work. nothing works..

@CennoxX
Copy link

CennoxX commented Feb 6, 2025

Tried the script fix.. Didn't work. nothing works..

Did you set the about:config flag?

@ChaosDMNS
Copy link

Yes

@ChaosDMNS
Copy link

Tampermonkey says the script is active on pages.. But it does nothing... no matter how I open a new tab. clicking back button does nothing.

@ChaosDMNS
Copy link

I'm using Firefox 1.3.5 Maybe that's why?

@CennoxX
Copy link

CennoxX commented Feb 7, 2025

It seems to be Firefox 135. When manipulating the history (like the addon Back2close and the little script above do), the history is still changed, but the back button is not activated. This is only made, when the user used the page / clicked on the site, before manipulating the history.

@markran
Copy link

markran commented Feb 16, 2025

Tip: I'm on FF 134.02 and the extension has been unreliable when ViolentMonkey was active. I got the extension working again by changing ViolentMonkey's settings to use Synchronous page mode.

Weirdly, it seemed to fail on tabs opened by clicking a bookmark but if I first opened a tab with CTRL-T and then click the bookmark (loading it into the tab just created with CTRL-T), the extension would work and close the tab. One difference I noticed was it seemed to fail when history.length was 1 but work when history.length was 2. The one site that didn't work for me was YouTube but only after starting to view a video. The extension closes the YouTube tab if I haven't started viewing a video yet. However, YouTube (and all other sites (so far)), do work with Alt-Left Arrow. It seems maybe YouTube is trapping the Backspace key.

Edit: I just tested with FF 135 and the behavior is slightly different. Now Alt-Left Arrow won't close any tab when there's no history left but Backspace does work everywhere except to close a YouTube tab after that tab has navigated away from the first page it was opened on. I guess I can live with that since it seems to work perfectly everywhere except YouTube.

Note: in all of the above I set "dom.allow_scripts_to_close_windows" to true in about:config

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

No branches or pull requests

7 participants