Skip to content

add option to always open new tabs in target window - #2

Open
lexelby wants to merge 1 commit into
jfsl:masterfrom
lexelby:lexelby/add-always-option
Open

add option to always open new tabs in target window#2
lexelby wants to merge 1 commit into
jfsl:masterfrom
lexelby:lexelby/add-always-option

Conversation

@lexelby

@lexelby lexelby commented Sep 10, 2018

Copy link
Copy Markdown

Recent versions of Chrome have nerfed the "open as app" functionality. Previously one could invoke Chrome from the command line like this:

chromium-browser --app=some-url

It would open the url in a popup window without the address bar or tab bar. Importantly, any links in the appified window that target _blank will open a tab in the main window rather than in the appified window.

I guess they're getting rid of that functionality or something? Now links just sort of open in the appified window, confusing the browser.

This extension was really close to what I wanted, so I added an option to open all new tabs in the main browser window (not just when alt-clicking). I also added the ability to skip specifying a target name, in which case the lowest-number window ID will be used (in my case, the main browser window).

I'm totally new to extension development, so please let me know if I've missed anything :)

@BagronkeN

Copy link
Copy Markdown

@lexelby This was exactly what I was looking for as well! I failed to find any extensions that did this, and found this one to be closest, and your addition is exactly what I'm looking for.

My use case is using two Chrome windows side by side, and I always want new tabs opened in window 1 to appear in window 2 instead.

However, it does not work when opening new tabs using middle mouse button, presumably because this does not use target = _blank in the same fashion. Do you think there's any way to add support to catch these events as well?

@lexelby

lexelby commented Jan 2, 2019

Copy link
Copy Markdown
Author

Yay, I'm glad I'm not the only person with this use case!

To be honest, this is where my knowledge of extension writing is very limited. I wonder if it might be possible to detect a middle click here: https://github.com/jfsl/open-in-specific-window/pull/2/files#diff-5ff5f030a93d13a9c0db8531ad0ad322R17

I use a TamperMonkey script in tandem with this extension. It forces the target to _blank for certain links in Jira:

(function() {
    'use strict';

    $(function() {
         setInterval(function() {
             $('a.external-link, a:not([class])').each(function () {
                 $(this).attr('target', '_blank');
             });
        }, 1000);
   });

Still doesn't solve your middle-click problem though.

@BagronkeN

Copy link
Copy Markdown

Thanks for the response and the tip! I've never done any extension writing, but I'll see what I can do.

Catching middle clicks is a bit hit and miss from my experience, but I recently made a TamperMonkey script that has managed to work pretty well so far, so I'll see if I can put this puzzle together.

I'll let you know if I make any progress :)

@PolaEdward

Copy link
Copy Markdown

Thank you @lexelby this functionality is exactly what I need, I hope @jfsl merge it.

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 this pull request may close these issues.

4 participants