Make "copy video link to clipboard" button work

This commit is contained in:
celestora 2023-05-28 20:20:28 +03:00
parent 9e80ce16f1
commit ccb392b228

View file

@ -181,6 +181,28 @@ function _bsdnEventListenerFactory(el, v) {
click: [ () => el.querySelector(".bsdn_contextMenu").style.display = "none" ] click: [ () => el.querySelector(".bsdn_contextMenu").style.display = "none" ]
}, },
".bsdn_copyVideoUrl": {
click: [
async () => {
let videoUrl = el.querySelector(".bsdn_video > video").src;
let fallback = () => {
prompt("URL:", videoUrl);
};
if(typeof navigator.clipboard == "undefined") {
fallback();
} else {
try {
await navigator.clipboard.writeText(videoUrl);
confirm("👍🏼");
} catch(e) {
fallback();
}
}
}
]
},
".bsdn_video > video": { ".bsdn_video > video": {
play: [ play: [
() => { () => {