Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jpluimers/87e6a95fb12e49439f70de001d6c8bf5 to your computer and use it in GitHub Desktop.
Save jpluimers/87e6a95fb12e49439f70de001d6c8bf5 to your computer and use it in GitHub Desktop.
Asks users for a youtube url and open it on youtube-nocookie.co
javascript:void%20function(){const%20a=window.prompt(%22Welke%20youtube%20video%20wil%20je%20bekijken%3F%22);if(a){const%20b=new%20URL(a).searchParams,c=b.get(%22v%22);if(c){window.open(%22https://www.youtube-nocookie.com/embed/%22+c)}else{const%20b=a.replace(%22https://youtu.be/%22,%22https://www.youtube-nocookie.com/embed/%22);b!==a%26%26window.open(b)}}}();
const url = window.prompt('Welke youtube video wil je bekijken?');
if (url) {
const search = new URL(url).searchParams;
const videoId = search.get('v');
if (videoId) {
const newUrl = 'https://www.youtube-nocookie.com/embed/' + videoId;
window.open(newUrl);
} else {
const newUrl = url.replace('https://youtu.be/', 'https://www.youtube-nocookie.com/embed/');
if (newUrl !== url) {
window.open(newUrl);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment