Wednesday, August 10, 2022

#1 2022-06-15 12:43:27 pm

PhilMac
Member
Registered: 2009-11-21
Posts: 7

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:

Applescript:

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

Orion has basic AppleScript support:

EyWtUa5.png

Offline

 

#2 2022-06-15 12:51:17 pm

estockly
Member
Registered: 2009-01-03
Posts: 80

Re: Using AppleScript in Orion browser

Try this:

Applescript:


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

Offline

 

#3 2022-06-15 12:52:16 pm

KniazidisR
Member
From:: Greece
Registered: 2019-03-03
Posts: 2443

Re: Using AppleScript in Orion browser

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

Applescript:


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:

Applescript:


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

Last edited by KniazidisR (2022-06-15 12:53:50 pm)


Model: MacBook Pro
OS X: Catalina 10.15.7
Web Browser: Safari 14.1
Ram: 4 GB

Offline

 

#4 2022-06-15 12:55:51 pm

PhilMac
Member
Registered: 2009-11-21
Posts: 7

Re: Using AppleScript in Orion browser

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?

Last edited by PhilMac (2022-06-15 12:57:17 pm)

Offline

 

#5 2022-06-15 01:45:09 pm

KniazidisR
Member
From:: Greece
Registered: 2019-03-03
Posts: 2443

Re: Using AppleScript in Orion browser

Applescript:


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

Last edited by KniazidisR (2022-06-15 01:46:23 pm)


Model: MacBook Pro
OS X: Catalina 10.15.7
Web Browser: Safari 14.1
Ram: 4 GB

Offline

 

#6 2022-06-16 08:02:09 am

PhilMac
Member
Registered: 2009-11-21
Posts: 7

Re: Using AppleScript in Orion browser

KniazidisR wrote:

Applescript:


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

Offline

 

#7 2022-06-16 08:42:02 am

Nigel Garvey
Moderator
From:: Warwickshire, England
Registered: 2002-11-20
Posts: 5551

Re: Using AppleScript in Orion browser

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:

Applescript:

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


NG

Online

 

#8 2022-06-16 09:01:03 am

PhilMac
Member
Registered: 2009-11-21
Posts: 7

Re: Using AppleScript in Orion browser

Nigel Garvey wrote:

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:

Applescript:

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

error "Can’t set URL of missing value to \"https://twitter.com\"." number -10006 from URL of missing value

Offline

 

#9 2022-06-16 10:22:20 am

estockly
Member
Registered: 2009-01-03
Posts: 80

Re: Using AppleScript in Orion browser

PhilMac wrote:

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?



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

Applescript:


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

Applescript:


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.

Last edited by estockly (2022-06-16 10:35:30 am)

Offline

 

#10 2022-06-16 01:28:28 pm

Nigel Garvey
Moderator
From:: Warwickshire, England
Registered: 2002-11-20
Posts: 5551

Re: Using AppleScript in Orion browser

estockly wrote:

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.


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

Applescript:

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.


NG

Online

 

#11 2022-06-16 01:51:33 pm

estockly
Member
Registered: 2009-01-03
Posts: 80

Re: Using AppleScript in Orion browser

Nigel Garvey wrote:

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



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.

Offline

 

#12 2022-06-16 03:42:56 pm

PhilMac
Member
Registered: 2009-11-21
Posts: 7

Re: Using AppleScript in Orion browser

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

tell window 1

…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:

Applescript:

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:

Applescript:

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

Last edited by PhilMac (2022-06-16 05:12:47 pm)

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)