From 08cb903acbc06ad01a30e99a4236c764e793e9cb Mon Sep 17 00:00:00 2001 From: Ryan Milner Date: Tue, 19 Mar 2019 16:38:43 +0000 Subject: [PATCH 1/3] Fixed trailing comma --- extension/manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extension/manifest.json b/extension/manifest.json index a3c138e..434b793 100644 --- a/extension/manifest.json +++ b/extension/manifest.json @@ -362,6 +362,6 @@ "matches": ["*://openload.co/*"], "js": ["plugin-api.js", "keysocket-openload.js"], "all_frames": true - }, + } ] } \ No newline at end of file From b46a5092eb3f0e7782fdf12861bdbcbf068e4dd6 Mon Sep 17 00:00:00 2001 From: rtm516 Date: Sun, 12 May 2019 19:18:58 +0100 Subject: [PATCH 2/3] Fixed BBC iPlayer support --- extension/manifest.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/extension/manifest.json b/extension/manifest.json index 4002ffb..6b6566e 100644 --- a/extension/manifest.json +++ b/extension/manifest.json @@ -364,7 +364,8 @@ }, { "matches": ["*://emp.bbc.co.uk/emp/*"], - "js": ["plugin-api.js", "keysocket-iplayer.js"] + "js": ["plugin-api.js", "keysocket-iplayer.js"], + "all_frames": true }, { "matches": ["*://openload.co/*"], From 1e50958323d752d9bf345df566b39b56f6a3eb44 Mon Sep 17 00:00:00 2001 From: Ryan Milner Date: Sat, 18 May 2019 18:49:10 +0100 Subject: [PATCH 3/3] Added Amazon Prime Video support --- README.md | 1 + extension/keysocket-prime.js | 15 +++++++++++++++ extension/manifest.json | 4 ++++ extension/plugin-api.js | 29 +++++++++++++++++++++++++++++ 4 files changed, 49 insertions(+) create mode 100644 extension/keysocket-prime.js diff --git a/README.md b/README.md index c2c9633..437a837 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,7 @@ when you're listening to music on various streaming websites. * 163 Music * 8tracks * Amazon Cloud Player + * Amazon Prime Video * Bandcamp * Birp * Bop diff --git a/extension/keysocket-prime.js b/extension/keysocket-prime.js new file mode 100644 index 0000000..78a4a8b --- /dev/null +++ b/extension/keysocket-prime.js @@ -0,0 +1,15 @@ +keySocket.init( + "prime", + function(key) { + if (key === keySocket.NEXT) { + var nextButton = document.querySelector(".fastSeekForward > img"); + keySocket.simulatePointer(nextButton); + } else if (key === keySocket.PLAY) { + var playPauseButton = document.querySelector(".playIcon > img, .pausedIcon > img"); + keySocket.simulatePointer(playPauseButton); + } else if (key === keySocket.PREV) { + var backButton = document.querySelector(".fastSeekBack > img"); + keySocket.simulatePointer(backButton); + } + } +); \ No newline at end of file diff --git a/extension/manifest.json b/extension/manifest.json index 6b6566e..75bb226 100644 --- a/extension/manifest.json +++ b/extension/manifest.json @@ -375,6 +375,10 @@ { "matches": ["*://www.jamendo.com/*"], "js": ["plugin-api.js", "keysocket-jamendo.js"] + }, + { + "matches": ["*://www.amazon.co.uk/gp/video/*"], + "js": ["plugin-api.js", "keysocket-prime.js"] } ] } diff --git a/extension/plugin-api.js b/extension/plugin-api.js index 1fef147..2a62fd0 100644 --- a/extension/plugin-api.js +++ b/extension/plugin-api.js @@ -104,6 +104,35 @@ keySocket.simulateClick = function (element, options) { return element.dispatchEvent(click); }; + +/** + * Use keySocket.simulatePointer to emulate user pointer click on web page control (button, link or other active element). + * + * @param element + * @param options + * @returns {boolean} + */ +keySocket.simulatePointer = function (element, options) { + if (!element) { + console.log('keysocket: cannot simulate click, element undefined'); + return false; + } + + var clickConfig = { + bubbles: true, + cancelable: false, + view: window + }; + if (options && options.cancelable) { + clickConfig.cancelable = options.cancelable; + } + + var clickDown = new PointerEvent('pointerdown', clickConfig); + var clickUp = new PointerEvent('pointerup', clickConfig); + return element.dispatchEvent(clickDown) && element.dispatchEvent(clickUp); +}; + + /** * keySocket.injectHandler is used for players that have an API on web page side. * Extension can't execute web page JS functions in raw way from the extension's scope.