Created
June 26, 2021 11:42
-
-
Save surajsau/5e5604457eab9313412911d9f6d7470d to your computer and use it in GitHub Desktop.
[Bookmarklet] Copy youtube link at the current timestamp
This file contains hidden or 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
javascript: ( | |
function (){ | |
var e = document.createElement('input'); | |
let ts = document.getElementsByClassName('time-first')[0].innerHTML; | |
let parts = ts.split(':'); | |
var inSeconds = 0; | |
if (parts.length == 3) { | |
inSeconds = (+parts[0]) * 3600 + (+parts[1]) * 60 + (+parts[2]); | |
} else { | |
inSeconds = (+parts[0]) * 60 + (+parts[1]); | |
} | |
e.value = location.href + "&t=" + inSeconds; | |
document.querySelector('body').append(e); | |
e.select(); | |
document.execCommand('copy'); | |
e.remove(); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment