Skip to content

Instantly share code, notes, and snippets.

@wilmoore
Last active January 31, 2025 10:26
Show Gist options
  • Select an option

  • Save wilmoore/73cb8c54c5496cc581a4fb5a8a1d20f6 to your computer and use it in GitHub Desktop.

Select an option

Save wilmoore/73cb8c54c5496cc581a4fb5a8a1d20f6 to your computer and use it in GitHub Desktop.
Software Engineering :: Web :: Browser :: Extension :: Development :: TitleSnatch for YouTube

Software Engineering :: Web :: Browser :: Extension :: Development :: TitleSnatch for YouTube

⪼ Made with 💜 by Polyglot.

related
research
Keyboard Shortcuts
  • [Playback speed] (+|-): (command + control|alt|option) + +|-
Notes (Screenshots)
  • Consider adding screenshot, screenshot with link to video at current time, and screenshot with link to video at current time and header (LLM => Header Text, or Enter Header Text Manually)

Selectors

NOTE: The title of the video is also in the title bar / title tag of the page

Video
document.querySelector('video')

Values & Calculations

Title
document.querySelector("#title > h1 > yt-formatted-string").textContent

Title

Video Current Time
const video = document.querySelector('video');
const videoCurrentTime = Math.floor(video.currentTime)
Video URL w/ Current Time
let newUrl = new URL(window.location.href);
newUrl.search = new URLSearchParams({
  v: newUrl.searchParams.get('v'),
  t: Math.floor(document.querySelector('video').currentTime)
});

Video URL w/ Current Time

Markdown Link Reference
(() => {
  const title = document.querySelector("#title > h1 > yt-formatted-string").textContent;

  let newUrl = new URL(window.location.href);
  newUrl.search = new URLSearchParams({
    v: newUrl.searchParams.get('v'),
    t: Math.floor(document.querySelector('video').currentTime)
  });

  console.log(`[${title}]: ${newUrl.href}`);
})();

Markdown Link Reference

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment