Skip to content

Instantly share code, notes, and snippets.

vitorgalvao / Get Title and URL.applescript
Last active July 19, 2024 10:51
AppleScript and JavaScript for Automation to get frontmost tab’s url and title of various browsers.
-- AppleScript --
-- This example is meant as a simple starting point to show how to get the information in the simplest available way.
-- Keep in mind that when asking for a `return` after another, only the first one will be output.
-- This method is as good as its JXA counterpart.
-- Webkit variants include "Safari", "Webkit", "Orion".
-- Specific editions are valid, including "Safari Technology Preview".
-- "Safari" Example:
tell application "Safari" to return name of front document
vitorgalvao / Prevent Dropbox Password
Last active June 6, 2024 08:47
Prevent Dropbox password dialog

If you don’t give Dropbox your password, it pesters you on startup. You can avoid that by setting 0000 permissions on the file, but that only lasts until the next Dropbox update. To make it permanent, we install a launchd job which will watch that file for changes and reset the permissions as we want them.

If you have Dropbox installed somewhere other than /Applications/, edit the plist accordingly.


mkdir -p "${HOME}/Library/LaunchAgents"
curl '' --output "${HOME}/Library/LaunchAgents/com.vitorgalvao.launchd.preventdropboxdialog.plist"
launchctl bootstrap "gui/$(id -u "${USER}")" "${HOME}/Library/LaunchAgents/com.vitorgalvao.launchd.preventdropboxdialog.plist"
vitorgalvao / Open New Tab In Specific Browser.js
Created February 11, 2023 19:01
JavaScript for Automation (JXA) for opening a new tab in different browsers
// JavaScript for Automation (JXA) for opening a new tab in different browsers.
// Doing an "open ''" and letting macOS handle it is usually preferable,
// but sometimes you want to specifically open a tab in a browser which is not the default.
// Chromium-based browsers
// Other examples include "Brave Browser", "Vivaldi"
const browser = Application("Google Chrome")
const newTab = browser.Tab({ url: "" })
vitorgalvao / Right Click.applescript
Last active March 16, 2023 14:30
Make right-clicking on OSX accessible via a keyboard shortcut
A [native solution][1] exists but it suffers from a major flaw: it right-clicks where the cursor is, not what on the selection.
This code addresses that limitation, though it only works on Finder windows and not the Desktop.
You can install it as a [Finder Service, and later asign it a keyboard shortcut][2].