Skip to content

Commit 6348919

Browse files
authored
Merge pull request #1 from aarblaster/safari-updates
New Script + Minor Updates
2 parents e157a46 + 4f0b52b commit 6348919

File tree

10 files changed

+110
-24
lines changed

10 files changed

+110
-24
lines changed

.DS_Store

0 Bytes
Binary file not shown.

Bartender/DisplaysLaptopOnly.scpt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,13 @@
33
-- A simple script to return `TRUE` when laptop screen is the only one.
44
-- Useful with Bartender Profiles
55
--
6-
-- Copyright Anthony Arblaster 2023
7-
-- MIT Licence
8-
-- Web: https://github.com/aarblaster/UsefulAppleScripts
6+
-- Copyright Anthony Arblaster 2023.
7+
-- – Web: https://codebyanthony.com
8+
-- – Mastodon: https://mastodonapp.uk/@aarblaster
9+
-- – GitHub: https://github.com/aarblaster
10+
--
11+
-- MIT Licence
12+
-- Repo: https://github.com/aarblaster/UsefulAppleScripts
913
--
1014
-- Version 1.0
1115
--

Bartender/DisplaysNotLaptop.scpt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,13 @@
33
-- A simple script to return `TRUE` when laptop screen is **NOT** the only one.
44
-- Useful with Bartender Profiles
55
--
6-
-- Copyright Anthony Arblaster 2023
7-
-- MIT Licence
8-
-- Web: https://github.com/aarblaster/UsefulAppleScripts
6+
-- Copyright Anthony Arblaster 2023.
7+
-- – Web: https://codebyanthony.com
8+
-- – Mastodon: https://mastodonapp.uk/@aarblaster
9+
-- – GitHub: https://github.com/aarblaster
10+
--
11+
-- MIT Licence
12+
-- Repo: https://github.com/aarblaster/UsefulAppleScripts
913
--
1014
-- Version 1.0
1115
--

Bunch/GetKMVar.scpt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,13 @@
33
-- A simple script get the variable from KM.
44
-- A building block really.
55
--
6-
-- Copyright Anthony Arblaster 2023
7-
-- MIT Licence
8-
-- Web: https://github.com/aarblaster/UsefulAppleScripts
6+
-- Copyright Anthony Arblaster 2023.
7+
-- – Web: https://codebyanthony.com
8+
-- – Mastodon: https://mastodonapp.uk/@aarblaster
9+
-- – GitHub: https://github.com/aarblaster
10+
--
11+
-- MIT Licence
12+
-- Repo: https://github.com/aarblaster/UsefulAppleScripts
913
--
1014
-- Version 1.0
1115
--

Bunch/QuitXcodeBunch.scpt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@
22
--
33
-- Quit Xcode, stopping running tasks.
44
--
5-
-- Copyright Anthony Arblaster 2023
6-
-- MIT Licence
7-
-- Web: https://github.com/aarblaster/UsefulAppleScripts
5+
-- Copyright Anthony Arblaster 2023.
6+
-- – Web: https://codebyanthony.com
7+
-- – Mastodon: https://mastodonapp.uk/@aarblaster
8+
-- – GitHub: https://github.com/aarblaster
9+
--
10+
-- MIT Licence
11+
-- Repo: https://github.com/aarblaster/UsefulAppleScripts
812
--
913
-- Version 1.0
1014
--

Email/EmailHi.scpt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,13 @@
44
-- Get the fist name of people in the email ‘To’ field.
55
-- With variants for Mail.app and MS Outlook.
66
--
7-
-- Copyright Anthony Arblaster 2023
8-
-- MIT Licence
9-
-- Web: https://github.com/aarblaster/UsefulAppleScripts
7+
-- Copyright Anthony Arblaster 2023.
8+
-- – Web: https://codebyanthony.com
9+
-- – Mastodon: https://mastodonapp.uk/@aarblaster
10+
-- – GitHub: https://github.com/aarblaster
11+
--
12+
-- MIT Licence
13+
-- Repo: https://github.com/aarblaster/UsefulAppleScripts
1014
--
1115
-- Version 3.0
1216
--

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@
2626

2727

2828
### URLs
29-
* `SafariToFirefox.scpt` opens the frontmost safari tab in firefox. Personally I trigger this with [Keyboard Maestro](https://keyboardmaestro.com)
29+
* `SafariToFirefox.scpt` opens the frontmost safari tab in Firefox. Personally I trigger this with [Keyboard Maestro](https://keyboardmaestro.com) using a string trigger.
30+
* `SafariToDuckDuckGo.scpt` opens the frontmost Safari tab in DuckDuckGo. Again I trigger with Keyboard Maestro. You could modify this for any app you fancy. The main difference with the Firefox script is that duck duck go has fewer weird tab opening problems. Hense there is a delay built into the firefox script.
31+
* `URLsToProfile.scpt` uses Keyboard Maestro to open specified URLs in the Safari profile of your choosing.
3032

31-
## Thanks
33+
## Thanks
3234
I'm not really amazing at any of this coding business, and I have only been able to work out these automations because of the excellent communities and software that others have made. I hope you find these useful.
33-
34-
If you do find them useful – give me a shout. I'd love to hear about that.
35+

URLs/SafariToDuckDuckGo.scpt

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
-- SafriToDuckDuckGo.scpt
2+
--
3+
-- A script to open the front Safari URL in DuckDuckGo.
4+
--
5+
-- Copyright Anthony Arblaster 2025.
6+
-- – Web: https://codebyanthony.com
7+
-- – Mastodon: https://mastodonapp.uk/@aarblaster
8+
-- – GitHub: https://github.com/aarblaster
9+
--
10+
-- MIT Licence
11+
-- Repo: https://github.com/aarblaster/UsefulAppleScripts
12+
--
13+
-- Version 1.0
14+
--
15+
16+
-- A Script to open the front tab in Safari in the DuckDuckGo browser.
17+
-- Requires that both browsers be installed.
18+
-- Trigger this script using any method you choose.
19+
-- I personally use Keyboard Maestro.
20+
21+
if application "Safari" is running then
22+
tell application "Safari"
23+
set safariURL to URL of front document
24+
end tell
25+
else
26+
set safariURL to "https://www.abc.net.au/news"
27+
end if
28+
29+
#Check if Firefox is already running
30+
if application "DuckDuckGo" is running then
31+
set duckWasRunning to true
32+
else
33+
set duckWasRunning to false
34+
end if
35+
36+
-- Activate DuckDuckGo
37+
tell application "DuckDuckGo" to activate
38+
39+
-- Check if DuckDuckGo was not running initially and there are open windows
40+
if not duckWasRunning then
41+
tell application "System Events"
42+
tell process "DuckDuckGo"
43+
if (count windows) is greater than 0 then
44+
# Close the front tab.
45+
keystroke "w" using {command down}
46+
#delay 1 # Add a delay to allow the tab to close
47+
end if
48+
end tell
49+
end tell
50+
end if
51+
52+
-- Open the URL in Firefox
53+
tell application "DuckDuckGo"
54+
open location safariURL
55+
end tell
56+

URLs/SafariToFirefox.scpt

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,21 @@
22
--
33
-- A script to open the front Safari URL in Firefox.
44
--
5-
-- Copyright Anthony Arblaster 2023
6-
-- MIT Licence
7-
-- Web: https://github.com/aarblaster/UsefulAppleScripts
5+
-- Copyright Anthony Arblaster 2023.
6+
-- – Web: https://codebyanthony.com
7+
-- – Mastodon: https://mastodonapp.uk/@aarblaster
8+
-- – GitHub: https://github.com/aarblaster
89
--
9-
-- Version 1.0
10+
-- MIT Licence
11+
-- Repo: https://github.com/aarblaster/UsefulAppleScripts
1012
--
13+
-- Version 1.1
14+
--
15+
16+
-- A Script to open the front tab in Safari in the Firefox browser.
17+
-- Requires that both browsers be installed.
18+
-- Trigger this script using any method you choose.
19+
-- I personally use Keyboard Maestro.
1120

1221
-- Get the frontmost tab URL in Safari
1322
tell application "Safari"

URLs/URLsToProfile.scpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
-- URLsToProfile.scpt---- A script to open some urls in a specific profile in Safari.---- Copyright Anthony Arblaster 2023-- MIT Licence-- Web: https://github.com/aarblaster/UsefulAppleScripts---- Version 2.0---- Open the new tab group-- Currently using Keyboard Maestro as the is no-- AppleScript, Shell or shortcuts was to do this.tell application "Keyboard Maestro Engine" to do script "KM_to_open_the_profile_you_want_to_use"-- Get URLS from a string-- The string containing URLs---- CHANGE THESE TO THE URLS YOU WANTset inputString to "https://github.com https://apple.com"-- Regular expression pattern to match URLsset urlPattern to "https?://\\S+"-- Create a list to store the extracted URLsset extractedURLs to {}-- Use the "do shell script" command with "grep" and regular expression to extract URLstry set extractedURLs to paragraphs of (do shell script "echo " & quoted form of inputString & " | grep -E -o " & quoted form of urlPattern)on error errMsg display dialog "An error occurred: " & errMsgend try-- Iterate through the extracted urls and open in tabs.tell application "Safari" -- Get a reference to the front window set frontWindow to the front window repeat with aURL in extractedURLs -- Create a new tab with the URL make new tab at frontWindow with properties {URL:aURL} end repeatend tell
1+
-- URLsToProfile.scpt---- A script to open some urls in a specific profile in Safari.---- Copyright Anthony Arblaster 2023.-- Ð Web: https://codebyanthony.com-- Ð Mastodon: https://mastodonapp.uk/@aarblaster-- Ð GitHub: https://github.com/aarblaster---- MIT Licence-- Repo: https://github.com/aarblaster/UsefulAppleScripts---- Version 2.0---- Open the new tab group-- Currently using Keyboard Maestro as the is no-- AppleScript, Shell or shortcuts was to do this.tell application "Keyboard Maestro Engine" to do script "KM_to_open_the_profile_you_want_to_use"-- Get URLS from a string-- The string containing URLs---- CHANGE THESE TO THE URLS YOU WANTset inputString to "https://github.com https://apple.com"-- Regular expression pattern to match URLsset urlPattern to "https?://\\S+"-- Create a list to store the extracted URLsset extractedURLs to {}-- Use the "do shell script" command with "grep" and regular expression to extract URLstry set extractedURLs to paragraphs of (do shell script "echo " & quoted form of inputString & " | grep -E -o " & quoted form of urlPattern)on error errMsg display dialog "An error occurred: " & errMsgend try-- Iterate through the extracted urls and open in tabs.tell application "Safari" -- Get a reference to the front window set frontWindow to the front window repeat with aURL in extractedURLs -- Create a new tab with the URL make new tab at frontWindow with properties {URL:aURL} end repeatend tell

0 commit comments

Comments
 (0)