Skip to content
This repository was archived by the owner on Nov 21, 2025. It is now read-only.

Commit b8c9afb

Browse files
authored
chore(docz-core): add missing openChrome.applescript (#1204)
* add missing openChrome.applescript * remove fb license
1 parent 3d7d8c1 commit b8c9afb

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
property targetTab: null
2+
property targetTabIndex: -1
3+
property targetWindow: null
4+
5+
on run argv
6+
set theURL to item 1 of argv
7+
8+
tell application "Chrome"
9+
10+
if (count every window) = 0 then
11+
make new window
12+
end if
13+
14+
-- 1: Looking for tab running debugger
15+
-- then, Reload debugging tab if found
16+
-- then return
17+
set found to my lookupTabWithUrl(theURL)
18+
if found then
19+
set targetWindow's active tab index to targetTabIndex
20+
tell targetTab to reload
21+
tell targetWindow to activate
22+
set index of targetWindow to 1
23+
return
24+
end if
25+
26+
-- 2: Looking for Empty tab
27+
-- In case debugging tab was not found
28+
-- We try to find an empty tab instead
29+
set found to my lookupTabWithUrl("chrome://newtab/")
30+
if found then
31+
set targetWindow's active tab index to targetTabIndex
32+
set URL of targetTab to theURL
33+
tell targetWindow to activate
34+
return
35+
end if
36+
37+
-- 3: Create new tab
38+
-- both debugging and empty tab were not found
39+
-- make a new tab with url
40+
tell window 1
41+
activate
42+
make new tab with properties {URL:theURL}
43+
end tell
44+
end tell
45+
end run
46+
47+
-- Function:
48+
-- Lookup tab with given url
49+
-- if found, store tab, index, and window in properties
50+
-- (properties were declared on top of file)
51+
on lookupTabWithUrl(lookupUrl)
52+
tell application "Chrome"
53+
-- Find a tab with the given url
54+
set found to false
55+
set theTabIndex to -1
56+
repeat with theWindow in every window
57+
set theTabIndex to 0
58+
repeat with theTab in every tab of theWindow
59+
set theTabIndex to theTabIndex + 1
60+
if (theTab's URL as string) contains lookupUrl then
61+
-- assign tab, tab index, and window to properties
62+
set targetTab to theTab
63+
set targetTabIndex to theTabIndex
64+
set targetWindow to theWindow
65+
set found to true
66+
exit repeat
67+
end if
68+
end repeat
69+
70+
if found then
71+
exit repeat
72+
end if
73+
end repeat
74+
end tell
75+
return found
76+
end lookupTabWithUrl

0 commit comments

Comments
 (0)