czukowski / tab-control-extension

Open tabs to the right, close to the left
https://addons.mozilla.org/firefox/addon/tab-control-addon/
MIT License
2 stars 0 forks source link

Compatibility issues #3

Open SonicTHI opened 5 years ago

SonicTHI commented 5 years ago

This extension breaks the "Undo Close Tab" extension - instead of closed tabs appearing in their original positions they reopen next to the current tab.

It also breaks the "New Tab Context" extension that should open new tabs next to the tab with the mouse cursor over. Instead the new tab opens next to the current active tab.

The plus button also opens a tab next to current instead of adding it at the end but i do not really use it so this is not a big deal.

I really want an "always open links right of current tab" option instead of the stupid "open links right of related tab" default behavior but rely on the above mentioned extensions. These issues are also present in all other similar extensions that i ve found but they have not been updated in a while so i am hoping you might be able to help.

Would it be possible to modify this or make an extension that only opens tabs to the right from "right click - open in new tab" or "middle click a link" interactions?

czukowski commented 5 years ago

The issue here is that the WebExtensions API used to create browser extensions does not provide any information on how or by whom a tab was created/moved/closed/etc, it just emits an event that it has. My extension listens to these events, checks the tab position and corrects it if deemed necessary. This, of course, may conflict with any extension that has to do with tabs positioning in any way and even some native browser functions such as Switch to Tab (#2).

I think it might be possible to inject scripts into web pages to try and handle link interactions only, but it's a totally different approach and I'm not sure it would be possible to handle all the possibilities (such as web pages opening tabs using JavaScript), it would also require some scary-looking permissions which I've been able to avoid so far.

That said, some time ago Mozilla has updated its API with a new tabs-related functionality, so in time they might also add something useful to achieve what you describe and then I'll be more than happy to update this extension.

SonicTHI commented 5 years ago

Relying on Mozilla would be about the last thing i would do. They broke all this in the first place with their retarded "be more like Chrome" mentality. If anything i expect them to break even more things in the future and give us more garbage that needs to be turned off.

I ve spent the past month trying to get 68esr to the same functionality i had with 52esr and a few addons and this is about the last major thing that infuriates me.

So i guess about the only way to do this currently would be to combine all 3 extensions and modify the code or can extensions interact in any way (flags, globals, settings, etc.)?

czukowski commented 5 years ago

Well, I have to say breaking down things that has worked well is a trend nowadays, but in case of Mozilla and WebExtensions there are plus sides to it as this platform provides much more secure environment even though it came at a cost. I wouldn't be so sure about Mozilla not being open to extending the API though, the new functionality I mentioned before (tab succession) has been proposed and implemented by a guy from outside of Mozilla and they accepted it. So I guess it's entirely possible, one just needs to come up with what exactly needs to be done and how to fit in the new feature in the existing API nicely, and then, of course, actually do it :)

As for extensions interacting with each other, to be honest, I don't know, but even if there is a way, I don't think it's the right one for this purpose. Extensions are meant to be isolated, if they could routinely talk to each other, it could get messy very quickly, as there are way too many extensions and each time someone makes a new one, it would be out of the loop and everybody would have to update their extensions until they all could work nicely with each others. Same thing with combining, everybody use different add-ons so there can hardly be a combination that fits all.

czukowski commented 5 years ago

Actually thinking about that new functionality gives me an idea, maybe there is a way to determine whether a tab position needs to be corrected or not by checking its successor property. Not sure it can work that way, will have to check.

DimkaDim commented 4 years ago

I created a bugreport about the

"always open links right of current tab" option instead of the stupid "open links right of related tab"

issue - https://bugzilla.mozilla.org/show_bug.cgi?id=1600128 So, vote:)

In WebExtensions API, for some situations it is possible to determine what kind of tab is being opened and apply or not apply correction to its position accordingly.

In my opinion, correction of tab's position is not needed when: 1) New tab is opened by "+" button. It can be determined by tab's address - it will be "about:newtab" (if user hasn't changed it) 2) New tab is opened by middle-clicking on a bookmark. API allows to access all bookmarks - a list of URLs of all bookmarks can be created (recursively iterate through all folders, example can be googled) on extension's launch, and every address of every new tab can be searched for in that list, and if exact match is found - we can assume that such new tab is opened by bookmark. This will also allow an session manager such as MySessions to open session's tabs in correct order, because it stores sessions as folders in bookmarks. 3) Recently closed tab is restored. For this one would have to combine functionality of this extension and "Undo Close Tab" - at least make a button for this extension to open last closed tab. So, this extension will be able to know when user restores last closed tab and not apply correction of its position because this extension will be the one that restores last closed tab AND the one that controls whether to correct its position.

I've already done points 1) and 2) by modifying "Tab Position Options" extension, but my implementation is a bit buggy in point 2) because I barely know JS and extension development, but someone determined can do everything in high quality.

DimkaDim commented 4 years ago

And, of course, in point 3) in case you just need to determine whether new tab is a reopening of the last closed tab, you can simply compare its address to the address of the last closed tab (available via corresponding API), so in the simplest case, you don't even need to merge the entire functionality of "Undo Close Tab"

czukowski commented 4 years ago

@DimkaDim the points you mention all involve privacy sensitive functions that the add-on must ask permissions for, and for what this extension does, I feel that asking for permissions is just wrong if it's needed only for a technical workaround and not the core add-on functionality, so I've been trying to avoid coming up with such compromises.

Also, with the URLs and the bookmarks, I think there may be a problem when the user opens a new tab whose URL that just happens to be bookmarked.

Of course, I would welcome if Mozilla implemented a native browser option to make tabs behave like that, but it's unlikely to happen, unless somebody's willing to send them a pull request. For the most part though, the add-on seems to work fine, despite some limitations. If your use case hits these limitations often, I would recommend to fork and modify the extension to suit your specific needs. I'm not a big expert on JS and the extensions development either, but the documentation provided by Mozilla is good for the most part and JavaScript is easy in general so if you want to go that way and run into issues, I might be able to offer some sort of advice :)

DimkaDim commented 4 years ago

"for what this extension does, I feel that asking for permissions is just wrong" It is possible to ask for optional permissions at runtime https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/permissions . You could leave install-time permissions as they are (no permissions), and create options page. 3 checkboxes: [ ] Open new tab created by "+" button to the right from all tabs [ ] Open tabs from Bookmarks to the right from all tabs [ ] Restore last closed tab at original position

If, for example, user checks option "Restore last closed tab at original position", ask for permissions to access recently closed tabs and to access browser tabs, and write an explanation below that option, why it will require these permissions if checked. I'm absolutely certain that all users who will see the problem with restoring closed tabs will gladly accept these permissions if that fixes the problem.

I think, after comparing with other such extensions, users would accept these permissions even at install-time, if you simply describe why they are required in extension's description. IMHO, problem-free functionality is far more important than catering to uninformed users. But again, compromise is not necessary in this case, install-time permissions can be left unchanged.

"there may be a problem when the user opens a new tab whose URL that just happens to be bookmarked." Yes, but: 1) let's suppose user bookmarked main page of a site. He is already somewhere on that site, opens several links by middle-clicking, and after that he clicks on link to main page. Is it really a bad thing that main page will open to the right from all already opened pages of that site? In many cases - probably not, because user wanted to start a new group of tabs anyway after going to the main page, by opening a new set of links from the main page. 2) After using my modification of "Tab Position Options" extension I can say that such a situation happens very rarely and almost never presents a problem. At least for me.

"I would welcome if Mozilla implemented a native browser option to make tabs behave like that, but it's unlikely to happen, unless somebody's willing to send them a pull request" Yes, they don't even see a problem with their "smart" grouping of related tabs, they certainly are not going to fix it themselves. They will either WONTFIX or set priority P5 to my bug report.

Thank you for offering help. But it's a question of the amount of effort required - someone who already wrote such an extension and knows web technologies can fix these issues in 30 times less time than me. I described ways to overcome these issues because you wrote "in time they might also add something useful to achieve what you describe and then I'll be more than happy to update this extension." and I knew that it is already achievable. But thank you anyway.

czukowski commented 4 years ago

@DimkaDim I guess I should have specified that I was talking about a functionality that is not useful only for a workaround that would have significant drawbacks of their own.

I wasn't aware of the optional permissions though, with those in mind these workarounds become much less of a problem. But in general, I would disagree about the install-time permissions. People usually don't read much beside the title and the first paragraph, so a request for permissions to 'access content of all the web pages' (not sure about the exact wording) would be a surprise to a lot of people, even if the reason is thoroughly described, trust me :)

The thing is, having an options page also requires a local storage permission, and I have, kind of, made a "promise" of no permissions or configuration necessary in the add-on description. I really believe that opening a new tab to the right and close to the left shouldn't need either of those, so I'll be always hesitant when it comes to breaking that promise (not saying that I won't ever budge though, but the reason must be really worth it). Maybe other extensions are aiming to be one-size-fits-all solutions, and as such they must ask for all kinds of permissions, but mine is nothing like that, it does only one thing (okay, two things 😀).

That's why I suggested you to make your own modification. I wrote this extension because the default browser behavior was bothering me a lot and I couldn't find any extension that would do exactly this. I had to read through some stuff, but it wasn't hard at all, you can see that the source code is very readable. I'm not sure about the workarounds you suggest though, they aimed at solving very specific issues you have, so the implementation might not be that straightforward at all and it's very likely my experience of writing this very simple add-on would not make me any more effective than you. And on top of that, you seem to have a very clear idea of what you're trying to achieve and how to do it, that's, like, half the job done :)

DimkaDim commented 4 years ago

Well, you're probably right about half the job already done. Maybe I'll try to modify somebody's extension after Mozilla implements Manifest v3. These constant changes to extensions framework always render all my previous efforts to modify something useless:)

DimkaDim commented 4 years ago

By the way, just out of interest, I just checked - this extension https://addons.mozilla.org/ru/firefox/addon/open-tabs-next-to-current/?src=search allows restoring last closed tab to its original position. And if I copy URL, close that tab, go to some other tab, paste that URL and middle-click on arrow (to go to that URL in new tab), it will not falsely reposition it, it will instead open it next to current tab (like it would open any other URL). So, somehow it does not have drawbacks where both of us thought it would. I didn't study its source code though.