Created
May 7, 2018 14:24
-
-
Save OKsign/e900686df508c8b04f483b118bfc58ba to your computer and use it in GitHub Desktop.
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
tell application "Google Chrome" | |
activate | |
delay 0.3 | |
set a to get title of front window | |
try | |
set AppleScript's text item delimiters to {"- "} | |
set siteName to last text item of a | |
end try | |
end tell | |
tell application "System Events" | |
set activeApp to (get name of first process where it is frontmost) | |
repeat 300 times | |
if activeApp is "Google Chrome" then | |
exit repeat | |
end if | |
end repeat | |
end tell | |
tell application "System Events" | |
keystroke "a" using command down | |
delay 0.3 | |
keystroke "c" using command down | |
delay 0.7 | |
set shortcut to the clipboard | |
delay 0.2 | |
set sTerm to "123456" | |
keystroke sTerm | |
delay 1 | |
key code 36 | |
delay 2 | |
end tell | |
tell application "System Events" | |
repeat 200 times | |
keystroke "l" using command down | |
delay 0.2 | |
keystroke "a" using command down | |
delay 0.2 | |
keystroke "c" using command down | |
delay 0.7 | |
set wURL2 to the clipboard | |
if wURL2 contains sTerm then | |
delay 0.02 | |
try | |
set prevTIDs to AppleScript's text item delimiters | |
set AppleScript's text item delimiters to the sTerm -- search | |
set the item_list to every text item of wURL2 -- original text | |
delay 0.04 | |
set AppleScript's text item delimiters to the "%s" -- replace | |
set pattern to the item_list as string | |
set AppleScript's text item delimiters to prevTIDs | |
end try | |
exit repeat | |
end if | |
end repeat | |
end tell | |
tell application "Google Chrome" | |
open location "chrome://settings/searchEngines" | |
set Wname to get title of front window | |
repeat 3000 times | |
set Wname to get title of front window | |
if Wname is "Settings" then | |
delay 0.02 | |
exit repeat | |
end if | |
end repeat | |
end tell | |
delay 3 | |
tell application "System Events" | |
keystroke "1]" -- search | |
delay 1 | |
keystroke "a" using command down | |
delay 0.5 | |
keystroke "c" using command down | |
delay 1 | |
set copT to the clipboard | |
delay 1 | |
-- def search box | |
if copT ends with "1]" then -- search box exists | |
delay 1 | |
key code 33 using command down -- back | |
delay 3 | |
repeat 4 times | |
delay 0.03 | |
key code 48 | |
end repeat | |
key code 36 | |
delay 0.2 | |
keystroke siteName | |
delay 0.9 | |
key code 48 | |
delay 0.9 | |
keystroke shortcut | |
delay 0.9 | |
key code 48 | |
delay 0.9 | |
keystroke pattern | |
delay 1 | |
key code 36 | |
delay 1 | |
keystroke "w" using command down | |
delay 1 | |
display notification "Done!" with title "script 6" | |
else | |
repeat 6 times | |
delay 0.03 | |
key code 48 | |
end repeat | |
key code 36 | |
delay 0.2 | |
keystroke siteName | |
delay 0.9 | |
key code 48 | |
delay 0.9 | |
keystroke shortcut | |
delay 0.9 | |
key code 48 | |
delay 0.9 | |
keystroke pattern | |
delay 1 | |
key code 36 | |
delay 1 | |
keystroke "w" using command down | |
delay 1 | |
display notification "Done!" with title "script 6" | |
end if | |
end tell |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment