Skip to content

Instantly share code, notes, and snippets.

@makhnanov
Last active March 1, 2024 12:55
Show Gist options
  • Save makhnanov/648d5d7ab54347f69241d2566eee374b to your computer and use it in GitHub Desktop.
Save makhnanov/648d5d7ab54347f69241d2566eee374b to your computer and use it in GitHub Desktop.
Bluetooth Headphones Pause = Next Track Workaround Yandex Music Script
// ==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