forked from raycast/script-commands
-
Notifications
You must be signed in to change notification settings - Fork 0
executable file
·35 lines (28 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/osascript
# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title Configure
# @raycast.mode compact
# Optional parameters:
# @raycast.icon images/duckduckgo_logo.png
# @raycast.argument1 { "type": "text", "placeholder": "@duck.com authorizationID" }
# @raycast.packageName DuckDuckGo Email Protection
# Documentation:
# @raycast.description Use this script command to configure your @duck.com authorizationID
# @raycast.author Rediwed
# @raycast.authorURL github.com/Rediwed
on run argv
set prefix to do shell script "curl -X POST https://quack.duckduckgo.com/api/email/addresses --header 'Authorization: Bearer " & (item 1 of argv) & "'"
if text 3 through 9 of prefix is "address" then
setAuthorizationID(item 1 of argv)
else
tell me to error "Could not configure authorizationID. Duck.com API result: " & prefix
end if
end run
on setAuthorizationID(authorizationID)
try
return do shell script "defaults write com.dpe.ddgEmailProtection AuthorizationID " & authorizationID
on error
tell me to error "Authorization ID not set, please run configure script command"
end try
end setAuthorizationID