pilotmoon / PopClip-Extensions

Source code extensions in the official PopClip Extensions directory.

Home Page:https://www.popclip.app/extensions/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Notion extension cannot retrieve the URL and title of Arc browser

ajason opened this issue · comments

commented

Notion extension cannot retrieve the URL and title of Arc browser

PopClip does not yet have fully support for Arc browser. I hope to add this in next version (if Arc will support it).

PopClip does not yet have fully support for Arc browser. I hope to add this in next version (if Arc will support it).

Let me know if Arc isn’t supporting it and if not, what’s required. Thanks!

Want the same feature.

Arc is based on Chromium, seems not very hard to incorporate it, hopefully it will work out.

Thanks a bunch.

@connor Thanks for commenting, sorry for the delay.

In most Chromium based browsers, PopClip uses a simple AppleScript command to retrieve browser URL/title:

tell application "Google Chrome"
  get URL of active tab of first window
end tell

Arc, however, does not implement this AppleScript API. If it did, or something similar, PopClip could use it.

@pilotmoon No problem.

Here is the documentation around our AppleScript APIs. You should be able to do:

tell application "Arc"
    get the URL of active tab of front window
end tell

Let me know if you need anything else. Thanks!

Awesome, thank you for the example and link. I didn't realise Arc already has an API for tabs.

Arc page info support has now shipped as a beta feature in PopClip Build 4183: https://www.popclip.app/beta

Hi @connor,

I wonder if you can advise on another scripting task for Arc.

I want to be able to open a url in Arc in a background tab in the front window, rather than as a new frontmost window. (This will be done when explicitly requested by the user.)

Currently I can do this for Safari and most Chromium-based browsers using scripts like the following, but am having difficulty adapting it for Arc.

Can you suggest an approach?

-- Safari versiopn -- opens in background tab by default
	tell front window of application id "com.apple.Safari"
		set newTab to make new tab with properties {URL: "https://example.com"}
	end tell
-- Chrome version, need to explicitly switch back to original tab (bit hacky but works OK)
	tell front window of application id "com.google.Chrome"
		set activeTabIndex to active tab index
		set newTab to make new tab with properties {URL:  "https://example.com"}
		set active tab index to activeTabIndex --switch back to original tab
	end tell

I can do something like

tell application "Arc"
		tell front window
			make new tab with properties {URL:"https://arc.net"}
			
			delay 5
			
			tell space 1
				make new tab with properties {URL:"https://thebrowser.company"}
			end tell
		end tell
	end tell

But this opens the tab as the foremost. Ideally, would be able to add a tab in the background (i.e. not focused)

EDIT

ok, this seems to do it

on openTab(theUrl, background)
	tell application id "company.thebrowser.Browser"
		tell front window
			set activeTabId to id of active tab
			make new tab with properties {URL:theUrl}
			if background then
				tell tab id activeTabId to select
			end if
		end tell
	end tell
end openTab

openTab("https://example.com", true)

@pilotmoon Hey, thanks for bringing this up! Apologies about the delayed response. Confirming you've got everything you need?

Yes, thanks @connor. I figured it out. Typing the question out to you got the old brain working enough to get me there. I appreciate the follow-up.