Created
August 29, 2015 19:48
-
-
Save AndrewZures/084eddb44a9995257578 to your computer and use it in GitHub Desktop.
minimize duplicate chrome tabs of same page
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local my_url, my_search | |
global search_terms | |
set my_url to "http://www.github.com" | |
set search_terms to {"github.com"} | |
tell application "Google Chrome" | |
if it is not running then | |
open location my_url | |
else | |
set result to my find_tab() | |
if (get status of result) then | |
set active tab index of (get _window of result) to (get tab_idx of result) | |
else | |
open location my_url | |
end if | |
end if | |
activate | |
end tell | |
on find_tab() | |
tell application "Google Chrome" | |
set my_search to "github.com" | |
set val to false | |
set window_list to every window | |
repeat with _window in window_list | |
set tab_list to every tab in _window | |
set tab_idx to 0 | |
repeat with _tab in tab_list | |
set tab_idx to tab_idx + 1 | |
set url_string to (URL of _tab as string) | |
repeat with search_term in search_terms | |
if search_term is in url_string then | |
return {status:true, _window:_window, tab_idx:tab_idx} | |
end if | |
end repeat | |
end repeat | |
end repeat | |
return {status:false} | |
end tell | |
end find_tab |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment