forked from yingDev/Web-Rtmp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreloadChrome.scpt
More file actions
executable file
·64 lines (54 loc) · 1.75 KB
/
reloadChrome.scpt
File metadata and controls
executable file
·64 lines (54 loc) · 1.75 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
on run {targetUrl}
tell application "Google Chrome"
activate
set theUrl to my remove_http(targetUrl)
if (count every window) = 0 then
make new window
end if
set found to false
set theTabIndex to -1
repeat with theWindow in every window
set theTabIndex to 0
repeat with theTab in every tab of theWindow
set theTabIndex to theTabIndex + 1
set theTabUrl to my remove_http(theTab's URL as string)
if (theTabUrl contains theUrl) then
set found to true
exit repeat
end if
end repeat
if found then
exit repeat
end if
end repeat
if found then
tell theTab to reload
set theWindow's active tab index to theTabIndex
set index of theWindow to 1
else
tell window 1 to make new tab with properties {URL:targetUrl}
end if
end tell
end run
on remove_http(input_url)
if (input_url contains "https://") then
return trim_line(input_url, "https://")
else
return trim_line(input_url, "http://")
end if
return input_url
end remove_http
-- Taken from: http://www.macosxautomation.com/applescript/sbrt/sbrt-06.html --
on trim_line(this_text, trim_chars)
set x to the length of the trim_chars
-- TRIM BEGINNING
repeat while this_text begins with the trim_chars
try
set this_text to characters (x + 1) thru -1 of this_text as string
on error
-- the text contains nothing but the trim characters
return ""
end try
end repeat
return this_text
end trim_line