-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
41 lines (36 loc) · 1.39 KB
/
index.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
31
32
33
34
35
36
37
38
39
40
41
// ==UserScript==
// @name Media button support for LINE Music
// @namespace https://reitn.no/
// @version 2.1
// @description Script to manually click the previoustrack and nexttrack buttons on LINE Msic's web page. Remember to press the Play button in the web UI before using any of the media buttons.
// @author johnedvard
// @match https://music.line.me/*
// @copyright 2021+, reitn.no
// @grant none
// ==/UserScript==
(function() {
'use strict';
function addMediaKeySupport() {
navigator.mediaSession.setActionHandler('previoustrack', function() {
document.getElementsByClassName('btn_play_prev')[0].click();
});
navigator.mediaSession.setActionHandler('nexttrack', function() {
document.getElementsByClassName('btn_play_next')[0].click();
});
console.log('media key support added');
}
function injectMonetizationTag() {
const metaEl = document.createElement('meta');
const moneAttr = document.createAttribute('name');
moneAttr.value = 'monetization';
const contentAttr = document.createAttribute('content');
contentAttr.value = '$ilp.uphold.com/Wb3kd4Jf3642'; // payment pointer ID
metaEl.setAttributeNode(moneAttr);
metaEl.setAttributeNode(contentAttr);
const headEl = document.getElementsByTagName('head')[0];
headEl.appendChild(metaEl);
console.log('monetization added');
}
addMediaKeySupport();
injectMonetizationTag();
})();