Last active
August 20, 2023 09:54
-
-
Save bessangel/25df93d8c26c20deedee9763919ef04d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name copy link to md | |
// @namespace http://tampermonkey.net/ | |
// @version 1.0.0 | |
// @description copy link to MD | |
// @author You | |
// @match https://*/* | |
// @match http://*/* | |
// @icon https://www.google.com/s2/favicons?domain=youtube.com | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
document.addEventListener('keydown', (e)=>{ | |
if( e.altKey & (e.key == 'c' /*en*/ || e.key == 'с' /*ru*/) ){ | |
let title = document.title; | |
let url = location.href; | |
let duration,views,published_at; | |
let channel=''; | |
if(/.*youtube.*/.test(url)){ | |
duration = document.querySelector('span.ytp-time-duration').innerText; | |
views =document.querySelector('span.view-count.ytd-video-view-count-renderer').innerText.replace(/[,]/g,'_').split(' ')[0]; | |
published_at =document.querySelector('#info-strings').innerText; | |
channel= document.querySelector('.ytd-channel-name a').innerText; | |
} | |
let t = `[${title}](${url}) %%\{${duration && "dur:'"+duration+"'," || ''} time:'${new Date().toTimeString().split(' ')[0]}', ${views && "views:'"+views+"'," || ''} ${published_at && "ctime:'"+published_at+"'," || ''} ${channel && "channel:'"+channel+"',"||''} \}%% `; | |
console.log(t) | |
navigator.clipboard.writeText(t); | |
} | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment