-
Notifications
You must be signed in to change notification settings - Fork 0
/
ContentScript.js
32 lines (25 loc) · 1005 Bytes
/
ContentScript.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
function getViD() {
url=document.location.href;
start=url.indexOf('v=')+2;
end=url.indexOf('&',start);
if (end==-1)end=url.length;
return url.substring(start, end);
}
function openPIP() {
chrome.extension.sendMessage({vid: getViD()});
}
var enclosure = document.createElement('span');
var but=document.getElementById('watch-like-dislike-buttons').firstElementChild.firstElementChild.cloneNode(false);
but.setAttribute('title', 'Picture In Picture');
but.removeAttribute('data-button-action');
but.setAttribute('id', 'watch-pip');
but.setAttribute('data-tooltip', 'Picture In Picture');
but.setAttribute('data-tooltip-title', 'Picture In Picture');
but.addEventListener('click', openPIP);
var span = document.createElement('span');
span.setAttribute('class', 'yt-uix-button-content');
var lab = document.createTextNode('PIP');
enclosure.appendChild(but);
but.appendChild(span);
span.appendChild(lab);
document.getElementById('watch-like-dislike-buttons').appendChild(enclosure);