Using AppleScript in Orion browser

I am trying to write an AppleScript in Orion, a new privacy-focused browser, that will open a new tab in the frontmost window with a specified URL.

Orion is in beta, and I’m inexperienced with AppleScript, so I can’t tell if the problem is with me or with the browser.

Any help would be appreciated!

What I have so far is:

tell application "Orion"
	make new tab at window 1 with properties {URL:"https://twitter.com"}
end tell

Orion has basic AppleScript support:

Try this:


tell application "Orion"
	tell window 1
		make new tab at beginning with properties {URL:"https://twitter.com"}
	end tell
end tell

I have not Orion browser installed, but looking at provided dictionary, I suggest following syntax:


tell application "Orion"
	make new tab at end of tabs of window 1 with properties {URL:"https://twitter.com"}
end tell

try simpler syntax as well:


tell application "Orion" to tell window 1
	make new tab with properties {URL:"https://twitter.com"}
end tell

Thanks to you both! For both my original attempt and your suggestions, when I run it the script in Script Editor, I get the result “missing value”. Any further thoughts?


tell application "Orion"
   make new document -- maybe this.  Creates window
   make new tab at end of tabs of window 1 with properties {URL:"https://twitter.com"}
end tell

Same thing, unfortunately—the result is “missing value”.

Hi.

With some properties of some applications, it’s necessary to make the element first and then set the property value. I don’t know if this is the case here, but it may be worth a try:

tell application "Orion"
	set newTab to (make new tab at window 1)
	set newTab's URL to "https://twitter.com"
end tell

Interesting—now it is throwing an error, including the words “missing value”:

This works for me. The result, yes, is missing value, but it does create a new tab in the window opened to that URL.


 tell application "Orion"
	tell window 1
		make new tab with properties {URL:"https://twitter.com"}
	end tell
end tell

I removed the “at beginning” part because Orion seemed to ignore that and make all new tabs at the end. (a bug)

Also, once you create a new tab, I don’t see a way to address it. There is a current tab property, but that errors; “last tab” errors; “every tab” errors.

Since this is in beta, maybe they will want to fix their AppleScript implementation?

EDIT: Try this…


tell application "Orion"
    tell window 1
        make new tab with properties {URL:"https://twitter.com"}
        set tabcount to number of tabs
        set myTab to tab tabcount
        tell myTab
            set tabName to its name
            set tabURL to its URL
        end tell
    end tell
end tell

I noticed that the Orion app doesn’t forget windows after they’re closed. For example, in my browser there’s only 1 open window, but Orion returns 16 windows from the number of windows command.

Seems pretty buggy.

These work for me in Mojave — provided the window’s included in the specifiers, of course.

tell application "Orion"
	activate
	tell window 1
		make new tab with properties {URL:"https://macscripter.net"} -- returns missing value, but works.
		make new tab with properties {URL:"https://www.bbc.co.uk/news"} -- ditto.
		tabs
		--> {tab 1 of window id 1820 of application "Orion", tab 2 of window id 1820 of application "Orion", tab 3 of window id 1820 of application "Orion"}
		set current tab to last tab -- selects rightmost tab, but returns nothing.
		--set current tab to first tab whose URL is "https://macscripter.net" --> errors.
		set current tab to first tab whose name is "MacScripter" -- works, but returns nothing. Needs time for the tab to load content and get named.
		--set current tab to tab named "MacScripter" -- ditto.
		--set current tab to tab "MacScripter" -- ditto..
		properties of every tab
		--> {{name:"Start Page", class:tab, URL:"orion://newtab/"}, {name:"MacScripter", class:tab, URL:"https://macscripter.net/"}, {name:"Home - BBC News", class:tab, URL:"https://www.bbc.co.uk/news"}}
	end tell
end tell

So tabs can be created, opened, and viewed, but there’s currently no way to get their content.

FYI, since Orion is in beta and and I checked out their website and they seem to have an active forum where the developer is interacting with users, and there are a few threads about their appleScript implementation.

I referred the developer here and to ScriptDebugger forums.

This is all fantastic—thanks so much!

This has helped me sort out another wrinkle: Orion’s “named windows” feature (sort of like Safari’s tab groups) means that if you write [format]tell window 1[/format] …then Orion looks for a window that is named “Window 1” rather than using the frontmost window.

I finally got the behavior I was looking for—though still with the “missing value” result—by specifying that I was referring to the window index:

 tell application "Orion"
    tell window index 1
        make new tab with properties {URL:"https://twitter.com"}
    end tell
end tell

And, if I want to switch to that tab, I draw on estockly’s method:

tell application "Orion"
	tell window index 1
		make new tab with properties {URL:"https://twitter.com"}
		set tabcount to number of tabs
		set myTab to tab tabcount
		tell myTab
			set tabName to its name
		end tell
		set current tab to first tab whose name is tabName
	end tell
end tell

I can’t get this to work with Chinese characters.
This script opens correctly in Safari, but creates a blank tab in Orion.

tell application "Orion"
	tell window index 1
		make new tab with properties {URL:"https://translate.google.com/?sl=auto&tl=en&text=更是"}
	end tell
end tell

Hi.

You need to replace the Chinese characters in the URL query with percent codes:

use AppleScript version "2.4" -- OS X 10.10 (Yosemite) or later
use framework "Foundation"

set chineseText to "更是"
set escapedText to ((current application's NSString's stringWithString:(chineseText))'s ¬
	stringByAddingPercentEncodingWithAllowedCharacters:(current application's NSCharacterSet's URLQueryAllowedCharacterSet())) as text
--> "%E6%9B%B4%E6%98%AF"

tell application "Orion"
	tell window index 1
		make new tab with properties {URL:"https://translate.google.com/?sl=auto&tl=en&text=" & escapedText}
	end tell
end tell

Thank you for the answer, but I can’t use framework “Foundation”
I used do shell script “open -a ‘Orion’ ‘https://translate.google.com/?sl=auto&tl=en&text=更是’”