Jump to content

Automator Service to open Universal Links without Web Browser


OSchrock

Recommended Posts

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.com/s/27xcop4g7r5a1x5/Open%20Acc%20Links%20in%20Acc.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

 

 

.

post-31975-0-11268200-1519421858_thumb.png

Edited by OSchrock
  • Like 3
Link to comment
Share on other sites

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

 

  • Like 3
Link to comment
Share on other sites

 

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

  • Like 1
Link to comment
Share on other sites

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
  • Like 2
Link to comment
Share on other sites

  • 2 weeks later...

Hello 

 

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

 

Greetings

 

Fabian

Link to comment
Share on other sites

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." 

Link to comment
Share on other sites

Hello Omar

 

Many thanks it works. 

 

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

 

Greetings

 

Fabian

Link to comment
Share on other sites

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
  • Like 1
Link to comment
Share on other sites

Thanks

 

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

 

Greetings

 

Fabian

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • 4 months later...

This AppleScript within Automator works fine when the link is "visible" (e.g., https://accordance.bible/link/search/KJVS?_%5BKEY_G2150%5D_),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.bible/link/search/KJVS?_%5BKEY_G2150%5D_)?

 

Thanks!

Edited by Ruben Gomez
Link to comment
Share on other sites

  • 1 year later...

I need help with the automator. I am unable to get it up and running. The hyperlinks are still taking me to the browser and not native accordance app.

  • Like 1
Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...