LinkThing - Isolate fast tab opening

35 views
Skip to first unread message

Joel Stickney

unread,
Nov 17, 2014, 5:13:26 AM11/17/14
to cani...@googlegroups.com
Just curious, but your extension LinkThing seems to eradicate that 1.5 second delay when left-clicking links with target="_blank." It was an unexpected side effect, but I kind of what a plugin that does that, and just that as LinkThing is overkill for my needs when I just want that feature. So, I thought I'd write a quick plugin to do so, and thought I'd ask you how you accomplished it.

Joel Stickney

unread,
Nov 17, 2014, 5:49:58 AM11/17/14
to cani...@googlegroups.com
This is not-related to the plugin, but I was curious (since you seem to be a Safari plugin connoisseur) - now that Safari has Private Windows, do you think it would be easy to replicate this: 


I use it all the time in Chrome and was curious if you knew if it's possible?

Canisbos Computing

unread,
Nov 17, 2014, 11:40:04 AM11/17/14
to cani...@googlegroups.com
Hi Joel,

Your extension will need two parts: an "injected script" that runs on every web page, and a "global page" that runs in the background, which can receive messages from the injected script and do things depending on them. (These terms are from Apple's developer guide for Safari extensions.)

The injected script will "listen" for clicks on a web page, and if a click is on a link that has target="_blank", it will (1) prevent the default action from occurring and (2) send a message to the global page. This message will contain the URL of the link. The global page, upon receiving this message, will use a method in Safari's extension API to open a new tab and set its URL to the URL in the message. This is what eliminates the wait -- which, by the way, I do not know why Safari imposes in the first place.

That's the high-level overview. If you want to get into the details, feel free to peruse the LinkThing source, which is available here:


You will want to look especially at the files injected.js and global.js.
Regards,
Chul



On Mon, Nov 17, 2014 at 2:13 AM, Joel Stickney <joelas...@gmail.com> wrote:

Just curious, but your extension LinkThing seems to eradicate that 1.5 second delay when left-clicking links with target="_blank." It was an unexpected side effect, but I kind of what a plugin that does that, and just that as LinkThing is overkill for my needs when I just want that feature. So, I thought I'd write a quick plugin to do so, and thought I'd ask you how you accomplished it.

--

---
You received this message because you are subscribed to the Google Groups "Canisbos Extensions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to canisbos+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Joel Stickney

unread,
Nov 17, 2014, 11:53:54 AM11/17/14
to cani...@googlegroups.com
That's perfect, I'll start working on that right away. I owe you :).

PS. Since I'm just starting out with Safari programming (and you're likely and expert with your 20 plugins) - do you know, with Yosemite and Safari's Private Windows - if it would be possible to replicate the functionality of this Chrome plugin with Safari:


It's incredibly useful :).

Canisbos Computing

unread,
Nov 17, 2014, 12:05:08 PM11/17/14
to cani...@googlegroups.com
Alas, there does not seem to be a way (using the official API) for an extension to start a private browsing session. If one already exists, it may be possible to move a tab from a non-private window into the private window—but this would depend on being able to tell which window is the private one, which I don't think is possible.

Chul

joelas...@gmail.com

unread,
Nov 17, 2014, 12:13:28 PM11/17/14
to Canisbos Computing, cani...@googlegroups.com
My dreams - they’re ruined. This link:


Seems to make reference to an EVENT that is triggered by entering into Private mode. If I’m on a tab and then open a new private window using cmd+shift+n then maybe an event could be triggered that grabs the previously active tab and shoves it into the newly created private window. I just can’t find any references to that event anymore. The page was updated July 15th, so I’m not certain they’ve included Yosemite Safari 8.0 in there.



You received this message because you are subscribed to a topic in the Google Groups "Canisbos Extensions" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/canisbos/YAxzX4ILj34/unsubscribe.
To unsubscribe from this group and all its topics, send an email to canisbos+u...@googlegroups.com.

Canisbos Computing

unread,
Nov 17, 2014, 12:15:11 PM11/17/14
to cani...@googlegroups.com
Bummer.

joelas...@gmail.com

unread,
Nov 17, 2014, 12:34:26 PM11/17/14
to Canisbos Computing, cani...@googlegroups.com
Yeah, but actually I think I may be able to get this to work, check this out:

Canisbos Computing

unread,
Nov 17, 2014, 12:41:41 PM11/17/14
to cani...@googlegroups.com, cani...@gmail.com
Yes, that refers to a Boolean property on the `activate` event that is fired when a tab or window is activated.

So, if the user switches to a private window, Safari will fire an `activate` event, and you can look for the `private` flag on it. Then, I guess you could move a specific tab from a non-private window into the private window.

Not the best UX, but perhaps better than nothing?

Chul
Bummer.




To unsubscribe from this group and stop receiving emails from it, send an email to canisbos+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--

---
You received this message because you are subscribed to a topic in the Google Groups "Canisbos Extensions" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/canisbos/YAxzX4ILj34/unsubscribe.
To unsubscribe from this group and all its topics, send an email to canisbos+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--

---
You received this message because you are subscribed to a topic in the Google Groups "Canisbos Extensions" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/canisbos/YAxzX4ILj34/unsubscribe.
To unsubscribe from this group and all its topics, send an email to canisbos+unsubscribe@googlegroups.com.

joelas...@gmail.com

unread,
Nov 17, 2014, 12:41:42 PM11/17/14
to Canisbos Computing, cani...@googlegroups.com
Essentially:

0. User creates a new private window using cmd+shift+n while on “google.com"
1. SafariPrivateBrowsing fires off an event with PrivateBrowsing variable Enabled BEFORE the new private window opens.
2. The extension grabs the current Safari window / tab - “google.com".
3. The extension waits a millisecond or two for the new private browsing window to open.
4. It then moves (or creates a new tab and closes the old one) the google.com tab into this new window / tab.

It might work if they updated the API to account for Private Browsing Windows.

Canisbos Computing

unread,
Nov 17, 2014, 12:43:56 PM11/17/14
to cani...@googlegroups.com, cani...@gmail.com
Sounds like a plan!
Bummer.




To unsubscribe from this group and stop receiving emails from it, send an email to canisbos+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--

---
You received this message because you are subscribed to a topic in the Google Groups "Canisbos Extensions" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/canisbos/YAxzX4ILj34/unsubscribe.
To unsubscribe from this group and all its topics, send an email to canisbos+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--

---
You received this message because you are subscribed to a topic in the Google Groups "Canisbos Extensions" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/canisbos/YAxzX4ILj34/unsubscribe.
To unsubscribe from this group and all its topics, send an email to canisbos+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages