1#!/usr/bin/env osascript
2# Get the URL of the frontmost Safari window.
4-- An AppleScript function to replace text. Yes, this is really
9-- replaceText("The cat is red", "red", "green")
10-- /* The cat is green */
12on replaceText(inputText, old, new)
13 set AppleScript's text item delimiters to the old
14 set the itemList to every text item of inputText
15 set AppleScript's text item delimiters to the new
16 set inputText to the itemList as string
17 set AppleScript's text item delimiters to ""
21tell application "Safari"
22 set frontmostUrl to URL of document 1
25-- Remove the localhost:5959 prefix from my book tracker running
26-- locally -- I never actually want this, just the relative path.
27set frontmostUrl to replaceText(frontmostUrl, "http://localhost:5959", "")
29-- Remove the localhost:5757 prefix from my personal site running
30-- locally -- I never actually want this, just the relative path.
31set frontmostUrl to replaceText(frontmostUrl, "http://localhost:5757", "")