Browse files

add next and prev

  • Loading branch information...
1 parent 3c10522 commit d55e99575dfc3ed1f197b8fe8789193349aa4382 @atsuya committed Dec 13, 2012
Showing with 62 additions and 3 deletions.
  1. +23 −0 chrome/next.scpt
  2. +16 −3 chrome/play-pause.scpt
  3. +23 −0 chrome/previous.scpt
View
23 chrome/next.scpt
@@ -0,0 +1,23 @@
+tell application "Google Chrome"
+ set targetTab to null
+ repeat with theWindow in every window
+ repeat with theTab in every tab of theWindow
+ if theTab's title ends with "- Google Play" then
+ set targetTab to theTab
+ exit repeat
+ end if
+ end repeat
+ end repeat
+
+ set code to "
+ var keyCode = 39;
+
+ var event = document.createEvent('Events');
+ event.initEvent('keydown', true, true);
+ event.keyCode = keyCode;
+ event.which = keyCode;
+
+ document.dispatchEvent(event);
+ "
+ execute targetTab javascript code
+end tell
View
19 chrome/play-pause.scpt
@@ -1,10 +1,23 @@
tell application "Google Chrome"
+ set targetTab to null
+ repeat with theWindow in every window
+ repeat with theTab in every tab of theWindow
+ if theTab's title ends with "- Google Play" then
+ set targetTab to theTab
+ exit repeat
+ end if
+ end repeat
+ end repeat
+
set code to "
+ var keyCode = 32;
+
var event = document.createEvent('Events');
event.initEvent('keydown', true, true);
- event.keyCode = 32;
- event.which = 32;
+ event.keyCode = keyCode;
+ event.which = keyCode;
+
document.dispatchEvent(event);
"
- execute front window's active tab javascript code
+ execute targetTab javascript code
end tell
View
23 chrome/previous.scpt
@@ -0,0 +1,23 @@
+tell application "Google Chrome"
+ set targetTab to null
+ repeat with theWindow in every window
+ repeat with theTab in every tab of theWindow
+ if theTab's title ends with "- Google Play" then
+ set targetTab to theTab
+ exit repeat
+ end if
+ end repeat
+ end repeat
+
+ set code to "
+ var keyCode = 37;
+
+ var event = document.createEvent('Events');
+ event.initEvent('keydown', true, true);
+ event.keyCode = keyCode;
+ event.which = keyCode;
+
+ document.dispatchEvent(event);
+ "
+ execute targetTab javascript code
+end tell

0 comments on commit d55e995

Please sign in to comment.