-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathyoutube-plus.user.js
30 lines (27 loc) · 1.07 KB
/
youtube-plus.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// ==UserScript==
// @name YouTubePlus
// @namespace http://tampermonkey.net/
// @version 0.2.1
// @match https://www.youtube.com/*
// @grant none
// @downloadURL https://github.com/henczi/userscripts/raw/master/youtube-plus.user.js
// ==/UserScript==
(function() {
'use strict';
(document.querySelector('video').onplay = function() {
setTimeout(function() {
const url = new URL(location.href);
const params = url.searchParams;
// Fixup media session keys (Chrome) - w history handling (POC)
if (url.pathname == '/watch' && params.get('v') && !params.get('list')) {
navigator.mediaSession.setActionHandler('nexttrack', () => {
document.querySelector('.ytp-next-button').click()
});
navigator.mediaSession.setActionHandler('previoustrack', () => {
window.history.back();
});
console.info('[*] Custom media key handlers loaded.');
}
}, 1000);
})()
})();