From 81fca079bc358617607d6b3b87e0552738c742a1 Mon Sep 17 00:00:00 2001 From: aKaravanov Date: Tue, 1 Oct 2019 00:26:48 -0700 Subject: [PATCH] Added support to Apple Music --- README.md | 3 ++- extension/keysocket-apple-music.js | 21 +++++++++++++++++++++ extension/manifest.json | 4 ++++ 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 extension/keysocket-apple-music.js diff --git a/README.md b/README.md index c2c9633..21e0d3b 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[![LICENSE](https://img.shields.io/badge/license-Apache_2.0-lightgrey.svg)](https://github.com/borismus/keysocket/blob/master/COPYING) +[![LICENSE](https://img.shields.io/badge/license-Apache_2.0-lightgrey.svg)](https://github.com/borismus/keysocket/blob/master/COPYING) [![Chrome Web Store](https://img.shields.io/chrome-web-store/users/fphfgdknbpakeedbaenojjdcdoajihik.svg)](https://chrome.google.com/webstore/detail/key-socket-media-keys/fphfgdknbpakeedbaenojjdcdoajihik) [![Chrome Web Store](https://img.shields.io/chrome-web-store/rating-count/fphfgdknbpakeedbaenojjdcdoajihik.svg)](https://chrome.google.com/webstore/detail/key-socket-media-keys/fphfgdknbpakeedbaenojjdcdoajihik) [![Chrome Web Store](https://img.shields.io/chrome-web-store/stars/fphfgdknbpakeedbaenojjdcdoajihik.svg)](https://chrome.google.com/webstore/detail/key-socket-media-keys/fphfgdknbpakeedbaenojjdcdoajihik) @@ -13,6 +13,7 @@ when you're listening to music on various streaming websites. * 163 Music * 8tracks * Amazon Cloud Player + * Apple Music * Bandcamp * Birp * Bop diff --git a/extension/keysocket-apple-music.js b/extension/keysocket-apple-music.js new file mode 100644 index 0000000..598b70d --- /dev/null +++ b/extension/keysocket-apple-music.js @@ -0,0 +1,21 @@ +keySocket.init( + "apple-music", + { + "play-pause": function () { + var playButton = document.querySelector('button[aria-label="Play"]'); + var pauseButton = document.querySelector('button[aria-label="Pause"]'); + if (pauseButton) { + keySocket.simulateClick(pauseButton); + } else { + keySocket.simulateClick(playButton); + } + }, + "prev": function(){ + keySocket.simulateClick(document.querySelector('button[aria-label="Previous"]')); + }, + "next": function(){ + keySocket.simulateClick(document.querySelector('button[aria-label="Next"]')); + } + // stop is omitted + } +); diff --git a/extension/manifest.json b/extension/manifest.json index 4002ffb..47db383 100644 --- a/extension/manifest.json +++ b/extension/manifest.json @@ -374,6 +374,10 @@ { "matches": ["*://www.jamendo.com/*"], "js": ["plugin-api.js", "keysocket-jamendo.js"] + }, + { + "matches": ["*://beta.music.apple.com/*"], + "js": ["plugin-api.js", "keysocket-apple-music.js"] } ] }