Last active
March 1, 2024 12:55
-
-
Save makhnanov/648d5d7ab54347f69241d2566eee374b to your computer and use it in GitHub Desktop.
Bluetooth Headphones Pause = Next Track Workaround Yandex Music Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Pause = Next Track Workaround Yandex Music Script | |
// @namespace http://tampermonkey.net/ | |
// @version 2024-03-01 | |
// @description try to take over the world! | |
// @author You | |
// @match https://music.yandex.ru/* | |
// @icon https://www.google.com/s2/favicons?sz=64&domain=yandex.ru | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
setInterval(() => { | |
navigator.mediaSession.setActionHandler("pause", (details) => { | |
const nextButton = document.getElementsByClassName('d-icon d-icon_track-next')[0]; | |
if (nextButton) { | |
nextButton.click(); | |
console.log('Clicked on the next button successfully.'); | |
} else { | |
console.log('Element not found. Make sure the class selector is correct.'); | |
} | |
console.log('Pause'); | |
}); | |
}, 1); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment