Posts tagged with "safari"

Chrome for iOS: Send A Webpage Back To Safari Via Bookmarklet

Sort of. Here’s a fun experiment.

Today, I wanted to quickly send a URL from Chrome for iOS – my default browser – back to Safari. I know there are ways to do Safari-to-Chrome, but I wanted the opposite: from Chrome back to Safari. I needed to install some custom Mr. Reader actions, and Chrome was giving an error when tapping on the downloadable files. I figured I could make a bookmarklet to take the current webpage in Chrome and send it to Safari.

Not so fast. There’s no documented URL scheme on iOS for opening web links in Safari, except, well, the http:// scheme itself. In testing various bookmarklet ideas, I thought that replacing googlechrome with http in Jon Abrams’ bookmarklet would force Chrome to send a link to Safari. But as It Turns Out™, doing this sort of trick in Chrome for iOS:

javascript:window.open('http'+location.href.substring(4));

…simply opens a new tab in Chrome.

What I ended up using is a hack – and a very curious one – to leverage Chrome’s support for x-callback-url to open a link back into Safari. I was inspired by Cormac Relf’s script, which I discovered yesterday when he showed me another script he made for Pythonista.

javascript:window.location='googlechrome-x-callback://x-callback-url/open/?url='+encodeURIComponent(location.href)+'&x-source=Safari&x-success='+encodeURIComponent(location.href);

As you can see above, we’re telling Chrome to open a new tab using…itself. The trick, at least theoretically, is to use an encoded location.href string to call back Safari, which is registered for the http:// scheme that Chrome, in this case, opens “externally”. Displaying x-source is needed per Google’s URL scheme specification; the name you give to x-source will be displayed as a “back” button in Chrome (as shown in the image above).

This is a profoundly inelegant and ultimately flawed solution. To make this “work” you have to:

  • Type the bookmarklet’s name, because Chrome has no bookmarks bar;
  • Nothing will happen.
  • Close Chrome;
  • Re-open it;
  • A wild new tab appears!
  • Tap the Safari button. It’s super-effective.
  • Safari will launch the link, closing the additional tab Chrome decided to open.

What is going on, exactly? Via JavaScript, we’ve forced Chrome to open a tab in itself, but doing so with x-callback-url inside a bookmarklet creates, for some reason, quite a strange behavior: the tab isn’t opened unless you close and re-open Chrome, therefore partially defeating the whole purpose of this bookmarklet, which is to quickly open a webpage in Safari. But, in spite of the clunky process, a new tab with a “Safari button” is created nevertheless, allowing you to tap it to launch Safari and close Chrome’s extra tab.

My conclusion is that we have three solutions: a) it’s not possible to create a straightforward Chrome-to-Safari bookmarklet; b) it’s possible in another way that I haven’t explored; or c) it’s possible with the x-callback-url hack, but in a different way.

If you have ideas, ping me on Twitter.


“Open In” and Mobile Safari

“Open In” and Mobile Safari

Continuing the discussion about the “Open In” menu for iOS, David Chartier proposes “Open In” for Safari URLs:

Finally, Document Sharing in Mobile Safari would further promote an app-centric workflow on iOS. Bookmarklets are often designed to open another web service in a new browser tab, and let’s face it, working on the web is a crummy experience. But even if they’re wired to open an app, bookmarklets are still a colossal pain to install which cuts off most attempts at the knees. This largely confines Mobile Safari and its content to an island, making iOS’s URL-to-app workflow needlessly tedious for anyone brave enough to try it.

In its current form, Mobile Safari only supports “Open In” for documents displayed in the browser, such as PDFs that Safari can render. The (new in iOS 6) share sheet doesn’t come with options to send a URL around, but only to copy it to the system clipboard.

Bookmarklets were never meant to take off among consumers, because they require a minimal amount of knowledge (or steps) that average users don’t want to deal with. However, developers had to resort to using bookmarklets because it was the only way to provide something that worked to pass a URL from Safari to a third-party app/web service. Some developers have gone out of their way to provide an “Install Bookmarklet” experience that wouldn’t scare off the majority of users.

Overall, “Open In” for links doesn’t sound like a bad idea. Imagine being able to quickly send a YouTube video to Facebook or a link to the Twitter app with an Apple-sanctioned menu and not some JavaScript hack. There are aspects I don’t know how I’d solve right now (How do supported apps appear in the iOS 6 share sheet? Are they available in a dedicated page, or can users re-arrange them? Could Siri be told to perform such actions?), but, generally speaking, providing better web-to-apps communication would be a good start.

Two years ago, Marco Arment offered some ideas on a possible “Send To” panel for Safari. This is absolutely still relevant today, because it hasn’t gotten better.

Obviously, that would be far from my envisioned iOS automation for power users. I’ve been trying the beta release of Alfred 2 lately, and I like how the developers created a workflow visualization that is both powerful and intuitive in the way it connects visually triggers to actions and outputs. Ideally, I’d love to see Apple considering an “Automator for iOS” – the kind of feature that most users don’t care about but that would likely make a subset of them reconsider iPads as “real work” machines. Apple could even go as far as making that kind of user automation look “cool” with the right interface decisions and a powerful inter-app communication layer that is not limited to Apple apps (read: with an API).

I hope this kind of stuff is in the cards for iOS 7.

Permalink

Automatically Send Articles From Reading List to Instapaper

Two days ago, Ben Brooks asked on App.net if anyone had come up with a way to share Safari Reading List items to Instapaper. His question made me realize that it would be a fun project to find out, so in my free time I put together a workflow that runs automatically and in the background on my Mac mini.

Please note, what follows is a raw experiment. I have tested it, and it works, but it’s far from stable. It uses GUI scripting in AppleScript to mark Reading List items as read, and it heavily depends on iCloud, which, unfortunately, is far from reliable when it comes to bookmark syncing. Nothing should happen to your bookmarks (the script simply “reads” them), but backups are recommended, as usual. Read more


Omnikey Simplifies Website-Specific Search In Safari

When I search the web for something, it’s mostly about music and artist discographies. Therefore I am used to the following typing workflow: “cmd+L” for toggling the URL bar, “en” to bring up the Wikipedia bookmark, open the site, and search there. I’ve often wished for a simpler key combination for quick access to such searches. Earlier this year I reviewed Bang On for iOS – a small app for easy website search on the iPhone and iPad. Using “!” as a toggling prefix you could create search commands for any website you can imagine, from Wikipedia to Amazon. It worked pretty well. I really wished for a similar functionality on the Mac.

Now, Safari users can have exactly this feature through a new extension called Omnikey, developed by Mario Estrada. Install it, and afterwards you’ll just need to type “wiki [search query]” into the Safari address bar to automatically open up the search results to your query on Wikipedia.org.

The “wiki” is the “omnikey” for toggling this kind of search. The same system also works for YouTube, Amazon, and some other websites out of the box. Put a “!” in front of your URL bar search query and Safari will use the default Google search. You can also easily add new websites you want quick Omnikey search for: just open up the extension’s editing panel in the toolbar, click “Add Site”, select a key for toggling the site search and paste a dedicated search query URL into the panel. Now you just have to replace the search query in the URL with a “{search}“ wildcard (like a software placeholder) and you’re done. I tried it with the MacStories search powered by DuckDuckGo, and it immediately worked.

Omnikey is a very handy Safari extension. It is lightweight, fast, and easy to use. Setting up new search keys is easy and works flawlessly. For people like me, who often need to search specific websites for links and information, Omnikey is a great companion. Download it for free at the project’s GitHub page.


Save Safari Tabs As A List in OmniFocus

Save Safari Tabs As A List in OmniFocus

This is a nice tip to save the tabs of the frontmost Safari window as a list in OmniFocus (via Shawn Blanc). Through AppleScript, tabs are saved as webpage titles and URLs in a note in the OmniFocus inbox; the note is named with the ”URL List from Safari Tabs” + timestamp format.

Using OmniFocus’ AppleScript Dictionary, you could modify the script to assign a specific context to the task for easy retrieval of your tab lists with Perspectives or OmniFocus’ own URLs. For the latter option, you can use Launch Center on iOS to quickly jump to OmniFocus projects and contexts; also keep in mind that any OmniFocus item (a task, a project, a context) has a unique ID that you can get using the “Copy as Link” option from the app’s contextual menu.

Permalink

Safari 6.0 and Google Search URLs

Safari 6.0 and Google Search URLs

Brent Simmons writes about the lack of URLs for Google searches in Safari 6.0:

I asked on Twitter. One way is to drag the magnifying glass into whatever text I’m editing. Another way would be a bookmarklet that gets the current page location. A third way would be an AppleScript script.

I ended up writing a Python script.

From my Mountain Lion review:

That said, there is one aspect to the new smart search field I don’t care for: it no longer displays Google Search URLs after you’ve used it to search for something. So if you want to share a direct link to a Google Search, you’ll need to copy it from the share sheet in either Messages or Mail.

In fiddling with Keyboard Maestro, I built a super-quick macro that grabs the URL of the frontmost Safari window through AppleScript. You can download the macro here, or check out the AppleScript itself if you want to create a system Service with Automator.

As pointed out by user @jaydisc on Twitter, some Apple apps on Mountain Lion can receive the copied search terms as clickable URLs in rich text format. In my tests, only Mail was able to receive search terms in RTF and, apparently, this is a known bug.

Permalink

Give Safari 6 Its RSS Back

Apple made the decision to remove RSS support from Mountain Lion with Mail (it felt out of place there anyway) and Safari 6 - no more RSS detection and easy-to-click buttons. RSS isn’t dead, so what can you do to get feed detection working again? One option is to download an older version of Safari, use an excellent 3rd party Mac app such as Reeder, or a new Safari extension (yeah, remember those?) by Daniel Jalkut of Red Sweater Software. It’s called Subscribe To Feed and in a blog post yesterday, he expressed his opinion about Apple’s decision and offers a solution to add RSS detection back to Safari 6.

My beta-quality, more-or-less unsupported Subscribe to Feed extension adds a handy button to the toolbar that, when a page offers RSS or Atom feeds, can be clicked to easily open the feed:// link, which should automatically open your favorite news reader.

I hope this extension fills a void for those of you missing the beloved RSS button from Safari 5 and earlier.

The extension not only works like it’s supposed to (this is beta?) but also matches the look and feel of Safari’s UI. When activated, it simply finds the RSS url and adds it /opens it in your default RSS app. The functionality really needed is the ability to view an RSS feed inside the browser but it does bring back the button functionality, which is nice. You can download Jalkut’s RSS extension on Red Sweater.

[Hat Tip TUAW]


Safari 6.0 Is Nathan Ingraham’s Next Browser

Safari 6.0 Is Nathan Ingraham’s Next Browser

Nathan Ingraham of The Verge writes,

But just as I’m getting fed up with Chrome, Apple goes ahead and launches Mountain Lion with Safari 6.0. With the addition of iCloud tab syncing across multiple OS X machines (which will finally come to iOS 6 this fall), integrated sharing to Twitter, a unified search and URL bar (finally), and a new gesture-based tab management system, I should be just as productive as I was in Chrome — but without the memory leaks and white screens. As a big fan of Apple’s gesturing system, I’m looking forward to pinch-and-swiping my way through the many tabs I have open all day long.

I love Nathan’s reminisce of Safari on the Mac, and how he, like myself, ended up using Chrome when working online became a priority.

I always have a hard time deciding between what browser to use on the Mac. While most of the websites I visit are now serving media to browsers without Flash plug-ins, there are still plenty of websites that don’t have HTML and Javascript substitues for Flash audio and video players. Chrome is convenient: Flash (while occassionally buggy) is built in, the browser handles having lots of tabs open quite well, and for a while, Chrome’s omnibox was advantageous over Firefox or Safari, whose separate address and search bars suddenly felt outdated. The decision is even harder now that Chrome is available on iOS.

Safari’s clean aesthetic, however, remains unchallenged. Safari’s experience is simply elegant, and I find myself missing the same features that Nathan has come to relish, such as Safari’s Reader, its superior support for gestures, and Apple’s implementation of the bookmarks bar. Safari gels with my idea of what the ideal browsing experience should be, and as with all of their apps, goes out of their way to include subtle pleasantries such as when a download jumps into the Downloads button. With Mountain Lion, Safari also includes the ability to open tabs from other devices, an important and recently added Chrome feature.

I think, for a little while, I’ll be returning to Safari as well. At least until I miss the ability to pin tabs when commenting on the next linked article.

You can learn more about Safari 6.0 for the Mac at apple.com/safari.

Permalink

Apple Releases Safari 5.1.4

Apple just released an update to Safari on its Downloads website and Software Update, adding a number of improvements for stability, compatibility, and security.

  • Improve JavaScript performance
  • Improve responsiveness when typing into the search field after changing network configurations or with an intermittent network connection
  • Address an issue that could cause webpages to flash white when switching between Safari windows
  • Address issues that prevented printing U.S. Postal Service shipping labels and embedded PDFs
  • Preserve links in PDFs saved from webpages
  • Fix an issue that could make Flash content appear incomplete after using gesture zooming
  • Fix an issue that could cause the screen to dim while watching HTML5 video
  • Improve stability, compatibility and startup time when using extensions
  • Allow cookies set during regular browsing to be available after using Private Browsing
  • Fix an issue that could cause some data to be left behind after pressing the “Remove All Website Data” button

You can find Safari 5.1.4 here. The previous version of Safari, 5.1.3, was released alongside 10.7.3, adding, again, bug fixes and improvements.