Jump to content


Photo

Automator Service to open Universal Links without Web Browser

automator script services URL URLs Links Universal Link

  • Please log in to reply
10 replies to this topic

#1 OSchrock

OSchrock

    Silver

  • Active Members
  • PipPipPip
  • 131 posts
  • Gender:Male
  • Location:USA / Brazil
  • Accordance Version:12.x
  • Platforms:Mac OS X

Posted 23 February 2018 - 04:39 PM

I just wrote a little Mac Automator script that will, within any app, open an Accordance universal link directly into Accordance without using a web browser

 

When you right-click on a universal link (https://accordance.bible/link/...) and choose to run this service, it replaces the universal URL with an Accordance specific URL and opens it directly in Accordance.

 

I'm sure others have done this, but I could not find it in the forums so I'll post my work here.  You can either create and tweak your own as I explain below, or just download the Service I created. https://www.dropbox....in Acc.zip?dl=0

 

 

Using Automator, create a new Service and set it to accept URLs.

 

Add two boxes for "Run AppleScript" and below them one box for "Run Shell Script."  (See screenshot)

 

----- 

 

The First AppleScript:

 

on run {input, parameters}

(*

Removes text "https://accordance.bible/link/" from the input URL

*)

set output to {} -- this will be the action's output

set textToRemove to "https://accordance.bible/link/" -- the text to remove

repeat with anItem in the input -- step through each item in the input

set {tempTID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, textToRemove}

set {textPieces, AppleScript's text item delimiters} to {text items of anItem, tempTID}

set the end of the output to textPieces as text

end repeat

return the output -- pass the result(s) to the next action

end run

 

 

 

The Second AppleScript:

 

on run {input, parameters}

(*

Prepends "accord://" to the input items

*)

set output to {}

set prepend_text to "accord://" -- the text to add

repeat with an_item in the input

set the end of output to (prepend_text & (an_item as text))

end repeat

return output

 

end run

 

 

 

The Shell Script: (with "Pass Input" set to "as arguments")

 

 

open "$1" -a /Applications/Accordance.app

 

 

-----  

 

I'm sure there is an easy way to combine the two scripts into one, but this works great. If you have suggestions to improve it, let me know below.

 

After you save it, it will appear as an option under "Services" when you right click on a URL.

 

 

 

(Edit: I completely understand, and appreciate, the need for Accordance to switch to the Universal links, but I use Evernote a lot and often want to skip the web-browser when clicking on Accordance links.)

 

 

 

- Omar

 

 

.

Attached Files


Edited by OSchrock, 23 February 2018 - 04:53 PM.

  • R. Mansfield and Fabian like this

#2 Joe Weaks

Joe Weaks

    Platinum

  • Active Members
  • PipPipPipPipPip
  • 1,334 posts
  • Gender:Male
  • Location:Odessa, TX
  • Interests:I like things that are Orange, and possibly Blue.
  • Accordance Version:11.x

Posted 24 February 2018 - 01:22 PM

This will take care of it all in one AS action.

 

on run {input, parameters}

    set textToRemove to "https://accordance.bible/link/"

    set textToAdd to "accord://"

 

repeat with anItem in the input

    set AppleScript's text item delimiters to textToRemove

    set textPieces to text items of anItem

    set AppleScript's text item delimiters to textToAdd

    set newURL to textPieces as text

    set AppleScript's text item delimiters to ""

    open location newURL

end repeat

    return

end run

 

 

Notes:

1. If you don't like `open location`, you can call the shell command with:

    do shell script "open " & quoted form of newURL & " -a /Applications/Accordance.app"

2. You really don't have to store and manage text item delimiters in a simple one routine snippet of script

 


  • OSchrock and Fabian like this
Joe Weaks
The Macintosh Biblioblog

Sometimes I'm so helpful even I can't stand it.

#3 OSchrock

OSchrock

    Silver

  • Active Members
  • PipPipPip
  • 131 posts
  • Gender:Male
  • Location:USA / Brazil
  • Accordance Version:12.x
  • Platforms:Mac OS X

Posted 24 February 2018 - 02:28 PM

 

This will take care of it all in one AS action.

 

on run {input, parameters}

    set textToRemove to "https://accordance.bible/link/"

    set textToAdd to "accord://"

 

repeat with anItem in the input

    set AppleScript's text item delimiters to textToRemove

    set textPieces to text items of anItem

    set AppleScript's text item delimiters to textToAdd

    set newURL to textPieces as text

    set AppleScript's text item delimiters to ""

    open location newURL

end repeat

    return

end run

 

 

Notes:

1. If you don't like `open location`, you can call the shell command with:

    do shell script "open " & quoted form of newURL & " -a /Applications/Accordance.app"

2. You really don't have to store and manage text item delimiters in a simple one routine snippet of script

 

 

Awesome! Thank you! I knew there must be easier ways to do it but just had to piece it together to get a workable setup.

 

 

- Omar


  • Fabian likes this

#4 Joe Weaks

Joe Weaks

    Platinum

  • Active Members
  • PipPipPipPipPip
  • 1,334 posts
  • Gender:Male
  • Location:Odessa, TX
  • Interests:I like things that are Orange, and possibly Blue.
  • Accordance Version:11.x

Posted 25 February 2018 - 12:30 AM

You did great for a first attempt, Omar. And great job posting so you could learn and all could benefit.

That's why I suggested the Accordance Forums add a subforum called something like "Accordance Automation" for discussing the ins and outs and uses for

1. accord:// and https://accordance.bible/link/links

2. Get Verses function
3. Accordance Services
4. Any scripting or other automation

  • OSchrock and Fabian like this
Joe Weaks
The Macintosh Biblioblog

Sometimes I'm so helpful even I can't stand it.

#5 Fabian

Fabian

    Mithril

  • Super Member
  • PipPipPipPipPipPip
  • 3,768 posts
  • Gender:Not Telling
  • Accordance Version:12.x
  • Platforms:Mac OS X, iOS

Posted 05 March 2018 - 03:41 AM

Hello 

 

How do I bring this to run? Copy paste to the Apple Script editor and then save wasn't successful.

 

Greetings

 

Fabian


Greetings

Fabian

ATTENTION: My bug reports are all with the GERMAN INTERFACE and with the EUROPEAN NOTATION! It can be the English interface has no bug, which I describe.

#6 OSchrock

OSchrock

    Silver

  • Active Members
  • PipPipPip
  • 131 posts
  • Gender:Male
  • Location:USA / Brazil
  • Accordance Version:12.x
  • Platforms:Mac OS X

Posted 05 March 2018 - 08:37 AM

Hello 

 

How do I bring this to run? Copy paste to the Apple Script editor and then save wasn't successful.

 

Greetings

 

Fabian

 

 

You'll need to create it inside of Automator - create a new service and add the "Run AppleScript" action. When you save it, you can run it by highlighting a link, right-clicking on it and then selecting the service in the context menu under "Services." 



#7 Fabian

Fabian

    Mithril

  • Super Member
  • PipPipPipPipPipPip
  • 3,768 posts
  • Gender:Not Telling
  • Accordance Version:12.x
  • Platforms:Mac OS X, iOS

Posted 05 March 2018 - 08:51 AM

Hello Omar

 

Many thanks it works. 

 

Is there no way it works automatic without going over Services?

 

Greetings

 

Fabian


Greetings

Fabian

ATTENTION: My bug reports are all with the GERMAN INTERFACE and with the EUROPEAN NOTATION! It can be the English interface has no bug, which I describe.

#8 Clint Cozier

Clint Cozier

    Bronze

  • Active Members
  • PipPip
  • 96 posts
  • Gender:Male
  • Location:Detriot, MI
  • Accordance Version:12.x
  • Platforms:Mac OS X, iOS

Posted 05 March 2018 - 09:30 AM

Fabian,

 

You can go to the keyboard Keyboard Control in your System Preferences then use the Shortcuts panel to assign a keyboard shortcut to the service. Once the keyboard shortcut is assigned, then the service can be run from all kinds of places: the keyboard, PopClip, or BetterTouchTool for example.


Edited by Clint Cozier, 05 March 2018 - 09:40 AM.

  • OSchrock likes this

#9 Fabian

Fabian

    Mithril

  • Super Member
  • PipPipPipPipPipPip
  • 3,768 posts
  • Gender:Not Telling
  • Accordance Version:12.x
  • Platforms:Mac OS X, iOS

Posted 05 March 2018 - 09:44 AM

Thanks

 

Yes I forgot, but I was thinking more of just a simple click.

 

Greetings

 

Fabian


Greetings

Fabian

ATTENTION: My bug reports are all with the GERMAN INTERFACE and with the EUROPEAN NOTATION! It can be the English interface has no bug, which I describe.

#10 Joe Weaks

Joe Weaks

    Platinum

  • Active Members
  • PipPipPipPipPip
  • 1,334 posts
  • Gender:Male
  • Location:Odessa, TX
  • Interests:I like things that are Orange, and possibly Blue.
  • Accordance Version:11.x

Posted 05 March 2018 - 04:51 PM

Yes I forgot, but I was thinking more of just a simple click.

Remember there is also a "Services" submenu in the contextual menu, so you can do a 'simple' right click/control click/two-finger click and then select the service from the submenu.


Joe Weaks
The Macintosh Biblioblog

Sometimes I'm so helpful even I can't stand it.

#11 Ruben Gomez

Ruben Gomez

    Gold

  • Accordance
  • 356 posts
  • Gender:Male
  • Location:Spain
  • Accordance Version:12.x
  • Platforms:Mac OS X, iOS

Posted 23 July 2018 - 10:39 AM

This AppleScript within Automator works fine when the link is "visible" (e.g., https://accordance.b..._[KEY_G2150]_),but is there any way to tweak it and make it work when the link is "hidden" (i.e., the selected text says "Accordance search" and "behind" it is the link itself -- https://accordance.b..._[KEY_G2150]_)?

 

Thanks!


Edited by Ruben Gomez, 23 July 2018 - 10:39 AM.

Rubén Gómez






Also tagged with one or more of these keywords: automator, script, services, URL, URLs, Links, Universal, Link

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users