Tidy up URLs from my book tracker
- ID
c5dab31- date
2024-09-25 17:53:48+00:00- author
Alex Chan <alex@alexwlchan.net>- parent
268e51d- message
Tidy up URLs from my book tracker- changed files
1 file, 24 additions, 1 deletion
Changed files
macos/furl (131) → macos/furl (871)
diff --git a/macos/furl b/macos/furl
index 76f4f25..88070f7 100755
--- a/macos/furl
+++ b/macos/furl
@@ -1,6 +1,29 @@
#!/usr/bin/env osascript
# Get the URL of the frontmost Safari window.
+-- An AppleScript function to replace text. Yes, this is really
+-- what it takes.
+--
+-- Example:
+--
+-- replaceText("The cat is red", "red", "green")
+-- /* The cat is green */
+--
+on replaceText(inputText, old, new)
+ set AppleScript's text item delimiters to the old
+ set the itemList to every text item of inputText
+ set AppleScript's text item delimiters to the new
+ set inputText to the itemList as string
+ set AppleScript's text item delimiters to ""
+ return inputText
+end replaceText
+
tell application "Safari"
- get URL of document 1
+ set frontmostUrl to URL of document 1
end tell
+
+-- Remove the localhost:5959 prefix from my book tracker running
+-- locally -- I never actually want this, just the relative path.
+set frontmostUrl to replaceText(frontmostUrl, "http://localhost:5959", "")
+
+get frontmostUrl