Russia has attacked Ukraine. We stand with Ukraine.
Partial income from our applications goes to support Ukraine.


OpenIn 4

Documentation - 08. JavaScript Editor for Rules

Table of content



Working with the Script Editor

You can configure a test URL to work with, and be able to Run the script to see the Result and Console Log output.


Depending on the type of the rule you are editing and for which handler, you can find some examples in the menu list under the Script Editor.

Available objects

ctx object is available for the script.

With the following methods and properties

  • url - returns the URL object
  • getSourceApp() - returns OpenContextSourceApp object, that can tell you if OpenIn recognized the application where link was opened
  • getApps() - returns the array of apps, where OpenIn logic already applied, but you can override it, array of OpenContextApp
  • isForPrinting() - (bool) check if file was requested to be opened for printing
  • getModifiers() - returns OpenContextModifiers object, that can tell which modifiers are pressed when link or file was requested to be opened by user
  • isShareMenu() - (bool) check if the link was sent by the Share Menu Open in OpenIn
  • isHandoff() - (bool) check if the link was sent by the Handoff in OpenIn
  • getFocusHint() - (string) get focus hint configured with the System Settings Focus (empty string if none is configured)

OpenContextSourceApp provides the following properties:

  • path - (string) the path of the application, that sent an open request

You can check if the opening app is Slack or other app. Just a note, when you open links from Slack, it is going to be a different app, that is under /Applications/, so to check if that is Slack app, you want to check if this path starts with path.

OpenContextApp provides the following properties:

  • name - the name of the app (string)
  • running - check if app is running (bool)
  • bundleIdentifier - the bundle identifier of the app (string)
  • visible - (bool) you can get or set this property, that is where you can apply your logic, for the list of the apps,
  • that you are getting from OpenIn, you can configure which one you want to see in the result list

URL provides the following properties:

  • fragement - everything after # (string)
  • host - hostname and port (string)
  • hostname - just a domain, hostname (string)
  • href - string representation of full url (string)
  • username - username (string)
  • password - password (string)
  • pathname - the path (string)
  • port - port (string)
  • protocol - scheme (string)
  • search - query of the url (string)
  • searchParams - object to work on url query (SearchParams)

SearchParams provides the object with the following methods

  • append(name, value) - append the search key value
  • delete(name) - delete all query items with the name
  • get(name) - get the first value of the query with name
  • getAll(name) - get all values as array of the query with name
  • has(name) - check if query has a key
  • set(name, value) - set the name and value for the search
  • keys() - get the array of all keys

OpenContextModifiers providers the object with the following properties

  • shift - shift pressed (bool)
  • option - option pressed (bool)
  • command - command pressed (bool)


You can use console.log("test") to write to a console output.


Example of the custom rule, that make decisions based on where the link is opened, and domains

(function() {
    // the list of available apps to send link to
    let apps = ctx.getApps()

    // if the source app (where link is opened is Slack, 
    // keep only Safari as visible app for OpenIn
    // and because we will have only one app left, 
    // OpenIn will just open the Safari
    if (ctx.getSourceApp().path.startsWith("/Applications/")) {
        apps.forEach(function (app) {
            app.visible = ( == "Safari")

    // all urls direct to Safari as well
    if (url.hostname.endsWith("")) {
        apps.forEach(function (app) {
            app.visible = ( == "Safari")

    // all urls direct to Safari and Chrome
    if (url.hostname.endsWith("")) {
        apps.forEach(function (app) {
            app.visible = ["Safari", "Google Chrome"].includes(