From ccb392b2288c9829d1b95644096f40e309744bf0 Mon Sep 17 00:00:00 2001 From: celestora Date: Sun, 28 May 2023 20:20:28 +0300 Subject: [PATCH] Make "copy video link to clipboard" button work --- Web/static/js/player.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Web/static/js/player.js b/Web/static/js/player.js index b170606f..7465f023 100644 --- a/Web/static/js/player.js +++ b/Web/static/js/player.js @@ -181,6 +181,28 @@ function _bsdnEventListenerFactory(el, v) { 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": { play: [ () => {