File tree Expand file tree Collapse file tree 2 files changed +22
-8
lines changed
Expand file tree Collapse file tree 2 files changed +22
-8
lines changed Original file line number Diff line number Diff line change 22
33keySocket . init (
44 "plex" ,
5- {
6- "play-pause" : "button[aria-label=\"Play\"], button[aria-label=\"Pause\"]" ,
7- "prev" : "button[aria-label=\"Previous\"]" ,
8- "next" : "button[aria-label=\"Next\"]"
9- // stop is omitted
5+ function ( key ) {
6+ if ( key === keySocket . NEXT ) {
7+ var nextButton = document . querySelector ( "button[aria-label=\"Next\"]" ) ;
8+ keySocket . simulateClick ( nextButton , { complex :true } ) ;
9+ } else if ( key === keySocket . PLAY ) {
10+ var playPauseButton = document . querySelector ( "button[aria-label=\"Play\"], button[aria-label=\"Pause\"" ) ;
11+ keySocket . simulateClick ( playPauseButton , { complex :true } ) ;
12+ } else if ( key === keySocket . PREV ) {
13+ var backButton = document . querySelector ( "button[aria-label=\"Previous\"]" ) ;
14+ keySocket . simulateClick ( backButton , { complex :true } ) ;
15+ }
1016 }
1117) ;
Original file line number Diff line number Diff line change @@ -93,9 +93,17 @@ keySocket.simulateClick = function (element, options) {
9393 if ( options && options . cancelable ) {
9494 clickConfig . cancelable = options . cancelable ;
9595 }
96- var clickDown = new MouseEvent ( 'mousedown' , clickConfig ) ;
97- var clickUp = new MouseEvent ( 'mouseup' , clickConfig ) ;
98- return element . dispatchEvent ( clickDown ) && element . dispatchEvent ( clickUp ) ;
96+
97+ console . log ( options ) ;
98+
99+ if ( options && options . complex ) {
100+ var clickDown = new MouseEvent ( 'mousedown' , clickConfig ) ;
101+ var clickUp = new MouseEvent ( 'mouseup' , clickConfig ) ;
102+ return element . dispatchEvent ( clickDown ) && element . dispatchEvent ( clickUp ) ;
103+ }
104+
105+ var click = new MouseEvent ( 'click' , clickConfig ) ;
106+ return element . dispatchEvent ( click ) ;
99107} ;
100108
101109/**
You can’t perform that action at this time.
0 commit comments