(() => { const fallbackCopyTextToClipboard = (text) => { let textArea = document.createElement("textarea"); textArea.value = text; textArea.style.top = "0"; textArea.style.left = "0"; textArea.style.position = "fixed"; document.body.appendChild(textArea); textArea.focus(); textArea.select(); try { let successful = document.execCommand('copy'); } catch (err) { console.error('Fallback: Oops, unable to copy', err); } document.body.removeChild(textArea); } const copyTextToClipboard = (text) => { if(!navigator.clipboard) { fallbackCopyTextToClipboard(text); return; } navigator.clipboard.writeText(text).then(() => { console.log('Async: Copying to clipboard was successful!'); }, (err) => { console.error('Async: Could not copy text: ', err); }); } const videoFeedUrls = document.querySelectorAll('div.video-feed-item.three-column-item a.video-feed-item-wrapper'); let urlArray = []; (videoFeedUrls).forEach((a) => { if(a.hasAttribute('href') && a.getAttribute('href')) { urlArray.push(a.getAttribute('href')); } }); let formattedUrls = urlArray.join(' '); console.log(formattedUrls); copyTextToClipboard(formattedUrls); })();