utubo / firefox-simple_gesture

🦊An add-on that adds simple touch gestures for Firfox for Android. Sorry, I only check issues sometimes.
https://addons.mozilla.org/ja/firefox/addon/simple-gesture/
Other
32 stars 1 forks source link

Is it possible to undo closed tabs? #74

Closed Wei-Winter closed 7 months ago

Wei-Winter commented 1 year ago

I don't seem to find it in the settings

utubo commented 1 year ago

It is not possible because the API is not supported. 😔

https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/sessions/restore

Wei-Winter commented 1 year ago

这是不可能的,因为不支持 API。 😔

https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/sessions/restore

I am an ios Orion user and have installed this extension of yours in the Firefox store and it works perfectly! See this link for the 38th api that is available to support this browser

https://browser.kagi.com/WebExtensions-API-Support.html

utubo commented 1 year ago

Thank you for Data ! I'll get right on it.

utubo commented 1 year ago

version 3.3 I added Reopen Closed Tab in Tab Gestures. You can turn on Enable experimental features to show it.

https://github.com/utubo/firefox-simple_gesture/commit/3c6b804ce967d38d22824b353c231fbd4a082763

utubo commented 1 year ago

I installed Orion to iPad Air. But, Reopen CLosed Tab does not work on Orion. This works on Firefox for Android. (Windows) 🤔

Wei-Winter commented 1 year ago

我将 Orion 安装到 iPad Air。 但, Reopen CLosed Tab不适用于猎户座。 这适用于 Android 版 Firefox。 (视窗) 🤔

Sorry, after my testing, it's really not possible to restore closed tabs, but I did achieve this using an extension from the chrome store, maybe this api doesn't have full support 🥺

utubo commented 1 year ago

OK. I'll leave the source code as is. Hopefully one day it will be supported. 🙏

Wei-Winter commented 1 year ago

This browser says it will port to support full api in the future 🤭

Dynamith commented 7 months ago

I have studied an alternative that can be used on the mobile side, and hope to be Merged into the code. It implements the function by listening to the creation, update and deletion of the tab page. The following is the code.

// background.js
    const exec = {
        // ......

        reopen: async () => {
            // const session = (await browser.sessions.getRecentlyClosed({ maxResults: 1 }))[0];
            // if (session) {
            //  browser.sessions.restore(session.tab ? session.tab.sessionId : session.window.sessionId);
            // }
            const url = simpleGesture_closedTabs.pop();
            if (url) browser.tabs.create({ active: true, url });
            else browser.tabs.executeScript({ code: `SimpleGesture.showTextToast('No recently closed tabs')` });
        },
        // ......
    };

    var simpleGesture_allTabs = new Map(
        (await browser.tabs.query({})).map((tabInfo) => [tabInfo.id, tabInfo.url])
    ), simpleGesture_closedTabs = [];
    browser.tabs.onCreated.addListener(tabInfo => simpleGesture_allTabs.set(tabInfo.id, tabInfo.url));
    browser.tabs.onUpdated.addListener((tabId, chgInfo) => { if (chgInfo.url) simpleGesture_allTabs.set(tabId, chgInfo.url) });
    browser.tabs.onRemoved.addListener(tabId => {
        let url = simpleGesture_allTabs.get(tabId);
        simpleGesture_allTabs.delete(tabId);
        if (!url.startsWith('about:')) {
            let index = simpleGesture_closedTabs.indexOf(url);
            if (index == -1) simpleGesture_closedTabs.push(url);
            else if (index < simpleGesture_closedTabs.length - 1) {
                simpleGesture_closedTabs.splice(index, 1);
                simpleGesture_closedTabs.push(url);
            }
        }
    });
utubo commented 7 months ago

This is a good code! I will merge this with some fixes this month.

Thanks for the code.

Dynamith commented 7 months ago

So your idea is to make the storage persistent for closedTabs, which is nice enough to get the behavior as close to browser.sessions as possible. I am looking forward to the next version.

utubo commented 7 months ago

I released v.3.14. 🎉 https://github.com/utubo/firefox-simple_gesture/commit/be31ec95d02abc8a330df78edb742066ecf94107