Skip to content

Commit a63ec78

Browse files
committed
Updated to allow for better fix configutation
1 parent 019ac62 commit a63ec78

File tree

2 files changed

+22
-8
lines changed

2 files changed

+22
-8
lines changed

extension/keysocket-plex.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,16 @@
22

33
keySocket.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
);

extension/plugin-api.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff 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
/**

0 commit comments

Comments
 (0)