-- Open Tweet in Browser
-- https://c-command.com/scripts/hibari/open-tweet-in-browser
-- Summary: Opens the selected tweet in the default Web browser.
-- Requires: Hibari
-- Install Location: ~/Library/Scripts/Applications/Hibari/
-- Last Modified: 2019-05-24



my openTweetInBrowser()

on openTweetInBrowser()
	set _oldClipboard to get the clipboard
	my copyHibariTweetURL()
	delay 1 -- otherwise clipboard may have stale value
	set _url to get the clipboard
	set the clipboard to _oldClipboard
	my openURL(_url)
end openTweetInBrowser

on copyHibariTweetURL()
	tell application "System Events"
		tell application process "Hibari"
			tell menu bar 1
				tell menu bar item "Tweets"
					tell menu 1
						tell menu item "Copy Tweet URL"
							click
						end tell
					end tell
				end tell
			end tell
		end tell
	end tell
end copyHibariTweetURL

on openURL(_url)
	do shell script "open " & _url's quoted form
end openURL
