1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 | on run argv
|
8 | set theURL to item 1 of argv
|
9 |
|
10 | tell application "Chrome"
|
11 |
|
12 | if (count every window) = 0 then
|
13 | make new window
|
14 | end if
|
15 |
|
16 |
|
17 | set found to false
|
18 | set theTabIndex to -1
|
19 | repeat with theWindow in every window
|
20 | set theTabIndex to 0
|
21 | repeat with theTab in every tab of theWindow
|
22 | set theTabIndex to theTabIndex + 1
|
23 | if theTab's URL is theURL then
|
24 | set found to true
|
25 | exit repeat
|
26 | end if
|
27 | end repeat
|
28 |
|
29 | if found then
|
30 | exit repeat
|
31 | end if
|
32 | end repeat
|
33 |
|
34 | if found then
|
35 | tell theTab to reload
|
36 | tell window 1
|
37 | activate
|
38 | end tell
|
39 | set index of theWindow to 1
|
40 | set theWindow's active tab index to theTabIndex
|
41 | else
|
42 | tell window 1
|
43 | activate
|
44 | make new tab with properties {URL:theURL}
|
45 | end tell
|
46 | end if
|
47 | end tell
|
48 | end run
|