-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathyoutube-share-link.user.js
38 lines (36 loc) · 1.02 KB
/
youtube-share-link.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
31
32
33
34
35
36
37
38
// ==UserScript==
// @name Youtube Share Link
// @namespace github.com/denniskupec
// @match https://www.youtube.com/*
// @grant none
// @version 1
// @author Dennis Kupec
// @run-at document-idle
// @noframes
// ==/UserScript==
function waitForElement(selector) {
return new Promise(resolve => {
const queryResult = document.querySelector(selector);
if (queryResult) {
return resolve(queryResult);
}
const observer = new MutationObserver(mutations => {
const queryResult = document.querySelector(selector);
if (queryResult) {
observer.disconnect();
resolve(queryResult);
}
});
observer.observe(document.body, { childList: true, subtree: true });
});
}
(function(){
waitForElement('yt-copy-link-renderer').then(item => {
const link = item.querySelector('#share-url');
item.addEventListener('click', () => {
let u = new URL(link.value);
u.searchParams.delete('si');
link.value = u.toString();
});
});
})();