Canal+ Player

Zap la pub vidéo canalplus

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

You will need to install an extension such as Tampermonkey to install this script.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği indirebilmeniz için ayrıca Tampermonkey gibi bir eklenti kurmanız gerekmektedir.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name Canal+ Player
// @description Zap la pub vidéo canalplus
// @namespace d19bfb8e-cacc-41f1-895b-9c2b5bd747be
// @author Reek
// @include *://*.d8.tv/pid*
// @include *://*.d8.tv/*/pid*
// @include *://*.d17.tv/pid*
// @include *://*.d17.tv/*/pid*
// @include *://*.mycanal.fr/pid*
// @include *://*.mycanal.fr/*/pid*
// @include *://*.canalplus.fr/pid*
// @include *://*.canalplus.fr/*/pid*
// @version 1.2
// ==/UserScript==

if (parent == self) { // skip frames

  // force redirection
  var lrefs = document.querySelectorAll('a');
  for (var j = 0, len = lrefs.length; j < len; ++j) {
    var lref = lrefs[j];
    if (lref.href.indexOf('?vid=') > -1) {
      lref.removeAttribute('onclick');
      lref.onclick = function () {
        location.href = this.href;
      };
    }
  }

  // waiting for video container
  setTimeout(function () {

    var getVideoId = function () {
      if (location.href.indexOf('?vid=') > -1) { // vod
        //console.log('vid in url');
        return location.href.split('?vid=')[1];
      } else if (typeof unsafeWindow.videoId !== 'undefined' && unsafeWindow.videoId !== '') { // vod
        //console.log('vid in dom');
        return unsafeWindow.videoId;
      }
      else { // live
	    //console.log('vid in flashvars');
        var flashvars = document.querySelector('embed#CanalPlayerEmbarque').getAttribute('flashvars');
        return flashvars.match(/videoId=([0-9]+)/)[1];
      }
    }
	
    var getParam = function () {
      return location.host.split('.')[1].replace('canalplus', 'cplus');
    }

    var container = document.querySelector('#CanalPlayerEmbarque');
    if (container) {
      var parent = container.parentNode;
      var player = document.createElement('div');
      player.innerHTML = '<embed title="Player without ads :-)" width="' + container.clientWidth + '" height="' + container.clientHeight + '" bgcolor="#000000" wmode="opaque" allowfullscreen="true" allowscriptaccess="always" flashvars="param=' + getParam() + '&amp;env=prod&amp;videoId=' + getVideoId() + '&amp;targetURL=&amp;timecode=1&amp;targetNewWindow=false&amp;autoplay=1" name="canalPlayer" src="http://player.canalplus.fr/site/flash/player.swf"><noembed>Veuillez installer Flash Player pour lire la vid&amp;eacute;o</noembed></object>';
      parent.replaceChild(player, container);
    }

  }, 5000);

}