Zing TV HTML5 Player Fix

Sửa player Zing TV trên Chrome

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Zing TV HTML5 Player Fix
// @namespace    http://tampermonkey.net/
// @version      1.0.1
// @description  Sửa player Zing TV trên Chrome
// @author       You
// @match        http://tv.zing.vn/video/*
// @grant        none
// ==/UserScript==
function loadJwPlayer(playerId,playerOption){
    var jw_js=document.getElementById('jw_js');
      if(typeof jw_js=='undefined'||jw_js==null){
        var head= document.getElementsByTagName('head')[0];
        var script= document.createElement('script');
        script.type= 'text/javascript';
        script.id="jw_js";
        script.src= 'https://content.jwplatform.com/libraries/QHJ5Iarr.js';
        //script.src='/js/jwplayer/jwplayer.js';
        head.appendChild(script);
        this.interval=setInterval(()=>{
          if (typeof jwplayer != 'undefined') {          
            jwplayer(playerId).setup(playerOption);
            clearInterval(this.interval);
          }
        },500);
      }
      else jwplayer(playerId).setup(playerOption);
}
(function() {
    if(navigator.userAgent.match(/Chrome/).length>0){        
    var script=$('script').text();
    var video_link=script.match(/http.*?.mp4/g);
    var sources=[];
    var quality=['360p','480p','720p'];
    for(var i=0;i<video_link.length;i++){
       sources.push({'file': video_link[i],'label': quality[i]});
	}
    console.log(sources);
    document.querySelector('._insideBackground').id='player';
    document.querySelector('._insideBackground').innerHTML='';
    loadJwPlayer('player',{'sources': sources,'autostart': true});
    }

})();