nicolafranchini/VenoBox

How to use Youtube no-cookie URL

Closed this issue · 2 comments

Hi,

is there a way to use the Youtube embed URL where no cookies are set? I get the player to work with normal youtube URLs but as soon as I replace https://www.youtube.com/ with https://www.youtube-nocookie.com/ the venobox script doesn't work anymore.

Example
Working:
https://www.youtube.com/embed/txCB6REY-1w

Not working with venobox:
https://www.youtube-nocookie.com/embed/txCB6REY-1w

Any help would be very appreciated!

Edit:
I copied the iframe opening tag from the venobox overlay - for some reason the src is undefined. I tested to set up an iframe manually direcly placed in my HTML and the video is loading fine. So somehow the js seems to have problems with
having https://www.youtube-nocookie.com as base of the URL.

<iframe
	class="venoframe vbvid vbox-figlio"
	webkitallowfullscreen=""
	mozallowfullscreen=""
	allowfullscreen=""
	allow="autoplay"
	frameborder="0"
	src="undefined?rel=0&amp;autoplay=1"
	style="padding: 0px; background: rgb(255, 255, 255);"
>

Hi,

after some investigation in you javascript I found a way to fix that issue. In venobox.js about lines 693 it works like this:

/* -------- LOAD VIDEOs -------- */
function loadVid(autoplay){

  // ... code before has no changes
  if (videoObj.type == 'vimeo') {
    player = 'https://player.vimeo.com/video/';
  } else if (videoObj.type == 'youtube-nocookie') {
    player = 'https://www.youtube-nocookie.com/embed/';
  } else if (videoObj.type == 'youtube') {
    player = 'https://www.youtube.com/embed/';
  }
  // ... code after has no changes
}

/**
* Parse Youtube or Vimeo videos and get host & ID
*/
function parseVideo (url) {
	// added match pattern: '|be-nocookie\.com' after 'be\.googleapis\.com'
	url.match(/(http:|https:|)\/\/(player.|www.)?(vimeo\.com|youtu(be\.com|\.be|be\.googleapis\.com|be-nocookie\.com))\/(video\/|embed\/|watch\?v=|v\/)?([A-Za-z0-9._%-]*)(\&\S+)?/);
	var type;
        // added if-statement for case 'youtube-nocookie.com' match in iframe src attribute:
	if (RegExp.$3.indexOf('nocookie') > -1) {
		type = 'youtube-nocookie';
	} else if (RegExp.$3.indexOf('youtu') > -1) {
		type = 'youtube';
	} else if (RegExp.$3.indexOf('vimeo') > -1) {
		type = 'vimeo';
	}
	return {
		type: type,
		id: RegExp.$6
	};
}

Would be really nice if you could have a look at this and in case you don't see any other issues arising from that fix merge that with your code :)

With the latest version you can use the data-vbtype iframe and the data-ratio, setting a link like this:

<a class="venobox" data-ratio="4x3" data-maxwidth="800px" data-gall="gall-video" data-vbtype="iframe" href="https://www.youtube-nocookie.com/embed/txCB6REY-1w">YOUTUBE NO COOKIE</a>