UNPKG

1.22 kBPlain TextView Raw
1-- Copyright (c) 2015-present, Facebook, Inc.
2-- All rights reserved.
3--
4-- This source code is licensed under the BSD-style license found in the
5-- LICENSE file in the root directory of this source tree. An additional grant
6-- of patent rights can be found in the PATENTS file in the same directory.
7on 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 -- Find a tab currently running the debugger
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
48end run