Last active
October 22, 2015 13:14
-
-
Save pesla/6ed38b2fd17b1bfdf515 to your computer and use it in GitHub Desktop.
Revisions
-
pesla revised this gist
Oct 22, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -22,7 +22,7 @@ on alfred_script(q) end repeat if found then set query to "zds = document.querySelector('.zd-searchmenu .zd-searchmenu-base'); if (zds) { zds.value = '" & ticketId & "'; zde = window.jQuery.Event('keydown'); zde.keyCode = 13; window.jQuery(zds).trigger(zde); }" as text tell theTab to set URL to "javascript:" & query set theWindow's active tab index to theTabIndex set winTitle to name of theWindow -
pesla revised this gist
Oct 22, 2015 . 1 changed file with 2 additions and 48 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -22,57 +22,11 @@ on alfred_script(q) end repeat if found then set query to "zds = document.querySelector('.zd-searchmenu .zd-searchmenu-base'); if (zds) { zds.value = '" & ticketId & "'; zde = window.jQuery.Event('keydown'); zde.keyCode = 13; window.jQuery('#mn_1').trigger(zde); }" as text tell theTab to set URL to "javascript:" & query set theWindow's active tab index to theTabIndex set winTitle to name of theWindow activate tell application "System Events" tell process "Google Chrome Canary" tell menu bar 1 -
pesla revised this gist
Oct 21, 2015 . 1 changed file with 15 additions and 8 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,18 +1,16 @@ on alfred_script(q) set ticketId to q set serverURI to "https://procurios.zendesk.com" set browserURL to "/tickets/" & ticketId set found to false tell application "Google Chrome Canary" if (count every window) > 0 then repeat with theWindow in every window set theTabIndex to 0 repeat with theTab in every tab of theWindow set theTabIndex to theTabIndex + 1 if URL of theTab starts with serverURI then set found to true exit repeat end if @@ -24,7 +22,6 @@ on alfred_script(q) end repeat if found then tell theTab execute javascript " (function() { @@ -70,21 +67,31 @@ on alfred_script(q) })(); " end tell set theWindow's active tab index to theTabIndex set winTitle to name of theWindow activate tell application "System Events" tell process "Google Chrome Canary" tell menu bar 1 click menu item winTitle of menu 1 of menu bar item -2 end tell end tell end tell end if end if end tell if not found then tell application "Google Chrome Canary" if (count every window) = 0 then make new window end if tell window 1 to make new tab with properties {URL:serverURI & browserURL} activate end tell end if end alfred_script -
pesla revised this gist
Oct 21, 2015 . 1 changed file with 88 additions and 51 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,53 +1,90 @@ on alfred_script(q) set ticketId to q set serverURI to "https://procurios.zendesk.com" set browserURL to "tickets/" & ticketId set found to false tell application "Google Chrome Canary" if (count every window) > 0 then 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 if URL of theTab starts with serverURI & "/agent" then set found to true exit repeat end if end repeat if found then exit repeat end if end repeat if found then activate tell theTab execute javascript " (function() { function fireKeyDownEventWithKeyCode(element, keyCode) { var oEvent = document.createEvent('KeyboardEvent'); // Chromium Hack Object.defineProperty(oEvent, 'keyCode', { get : function() { return this.keyCodeVal; } }); Object.defineProperty(oEvent, 'which', { get : function() { return this.keyCodeVal; } }); if (oEvent.initKeyboardEvent) { oEvent.initKeyboardEvent('keydown', true, true, document.defaultView, false, false, false, false, keyCode, keyCode); } else { oEvent.initKeyEvent('keydown', true, true, document.defaultView, false, false, false, false, keyCode, 0); } oEvent.keyCodeVal = keyCode; if (oEvent.keyCode !== keyCode) { console && console.log('keyCode mismatch ' + oEvent.keyCode + '(' + oEvent.which + ')'); } element.dispatchEvent(oEvent); } var searchBar = document.querySelector('.header-search input'); if (!searchBar) { return; } searchBar.value = " & ticketId & "; fireKeyDownEventWithKeyCode(searchBar, 13); })(); " end tell set theWindow's active tab index to theTabIndex set index of theWindow to 1 end if end if end tell if not found then tell application "Google Chrome Canary" activate if (count every window) = 0 then make new window end if tell window 1 to make new tab with properties {URL:serverURI & browserURL} end tell end if end alfred_script -
pesla revised this gist
Oct 21, 2014 . 1 changed file with 12 additions and 13 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -3,52 +3,51 @@ on alfred_script(q) set serverURI to "https://procurios.zendesk.com" set browserURL to "#/tickets/" & ticketId set found to false tell application "Google Chrome" if (count every window) > 0 then 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 if URL of theTab starts with serverURI & "/agent" then set found to true exit repeat end if end repeat if found then exit repeat end if end repeat if found then activate tell theTab execute javascript "function goToTicket() { URI = '" & browserURL & "'; if (Zd && Zd.Routes) { Zd.Routes.goToHashNow(URI); } } goToTicket();" end tell set theWindow's active tab index to theTabIndex set index of theWindow to 1 end if end if end tell if not found then tell application "Google Chrome" activate if (count every window) = 0 then make new window end if tell window 1 to make new tab with properties {URL:serverURI & browserURL} end tell end if end alfred_script -
pesla renamed this gist
Oct 21, 2014 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
pesla created this gist
Oct 21, 2014 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,54 @@ on alfred_script(q) set ticketId to q set serverURI to "https://procurios.zendesk.com" set browserURL to "#/tickets/" & ticketId set found to false tell application "Google Chrome" if (count every window) > 0 then 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 if URL of theTab starts with serverURI then set found to true exit repeat end if end repeat if found then exit repeat end if end repeat if found then activate set theWindow's active tab index to theTabIndex set index of theWindow to 1 tell theWindow's active tab execute javascript "function goToTicket() { URI = '" & browserURL & "'; if (Zd && Zd.Routes) { Zd.Routes.goToHashNow(URI); } } goToTicket();" end tell end if end if end tell if not found then tell application "Google Chrome" activate if (count every window) = 0 then make new window end if tell window 1 to make new tab with properties {URL:browserURL} end tell end if end alfred_script