Canal+ Player

Zap la pub vidéo canalplus

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==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);

}