Skip to content

Instantly share code, notes, and snippets.

@surajsau
Created June 26, 2021 11:42
Show Gist options
  • Save surajsau/5e5604457eab9313412911d9f6d7470d to your computer and use it in GitHub Desktop.
Save surajsau/5e5604457eab9313412911d9f6d7470d to your computer and use it in GitHub Desktop.
[Bookmarklet] Copy youtube link at the current timestamp
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