A Tampermonkey (and other *monkey) script to extract YT ID(s) from most YT pages with a single click
I wanted an easy one click solution to grab every YouTube ID from a page, then give me a neat list without duplicates ready for use elsewhere. I also fancied brushing up on my Tampermonkey/Javascript skills so though I would give it a go. I set to work throwing a solution together and ended up with this, it's a fairly neat solution that adds a discrete 📋 button at the top of most pages, clicking it will either copy the current URL if you are watching a video or short, or on a playlist style page you'll get every a list of every URL on the page.
- Quick and easy to use
- Should work with most *monkey variants: Tested/Developed with Chrome Tampermonkey v4.18.1, Also tested on Firefox Greasemonkey 4.11 (from 2021)
- Auto updates if your *monkey variant supports it
- The easiest way to install this is to click this link:
💾 YT-URL-Extractor.user.js
most *monkey's auto install features will then take care of things, this also can be used to manually trigger an update. - OR, view the YT-URL-Extractor.user.js and then click the
RAW
button, if you wish to check out the code first. - OR, Download or Copy/Paste the YT-URL-Extractor.user.js into your *monkey, save and activate.
Next time you vist a supported page (you may need to refresh if you are already on a YT page) you will see a small clipboard icon 📋 next to the mic icon at the top of the page.
Give that a click and a banner will briefly flash to let you know it's done it job.
Paste your output wherever you need it, depending on the page there will be two outcomes:
-
On a single video or short page you'll get just the URL from the video you are watching in this style https://youtu.be/8jMPgvaOXH8, I know there is the share button, this saves a couple of clicks.
-
On a playlist page or where multiple videos are diplayed you'll get a nice list like this:
https://youtu.be/UzE1njGyTBw
https://youtu.be/W48MqXVUYFI
https://youtu.be/a8_GYCiYmWI
https://youtu.be/hsyH84UP2Ns
https://youtu.be/Hmh6nGYKCEs
https://youtu.be/0IZP_oX_6Ic
https://youtu.be/8ZKzx1C4-DY
https://youtu.be/2g3m9p35cDo
https://youtu.be/KABSYzPqTTg
https://youtu.be/9ca2K5bJpvU
https://youtu.be/G0XntICXcyA
https://youtu.be/gpxUcIJ1tGs
https://youtu.be/Ei2cD61Je7A
https://youtu.be/SfpUM5Wrh2A
https://youtu.be/quI772XuCpo
https://youtu.be/YioAD0gQQSM
https://youtu.be/H2t7lknrK28
https://youtu.be/4RXdusySjsk
https://youtu.be/Z5ezsReZcxU
If you are on a channels homepage and they have some sort of carousel/spinner thing, you'll only get the ID's for the items you can see, the others are not generated/rendered until you bring them into view. I decided to leave it there after coding it but it's not much use on that page.
- Code optimisation: Code is fast enough but I'm sure there are a couple of things that could be better
- Add clipboard button to individual videos links, quickly grab individual URLs as well as whole page
- Add auto update
Published under the The Unlicense
- The check current URL code is derived from resu @ Stackoverflow and is used under their CC BY-SA 4.0 License
- The handy check clipboard code is by Mordo95 @ Reddit
If you fancy buying me a ☕ to say thanks, please visit my Ko-Fi page by hitting the button below.