Skip to content

Instantly share code, notes, and snippets.

@lixiaoyan
Last active December 23, 2015 19:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lixiaoyan/6680198 to your computer and use it in GitHub Desktop.
Save lixiaoyan/6680198 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name 乐视网
// @match http://www.letv.com/ptv/vplay/*
// ==/UserScript==
(function(vid){
var list=["720p","350"];
var box=document.querySelector("#fla_box");
var embed=box.querySelector("embed");
box.removeChild(embed);
GM_xmlhttpRequest({
method:"GET",
url:"http://www.letv.com/v_xml/"+vid+".xml",
onload:function(res){
var doc=new DOMParser().parseFromString(res.responseText,"text/xml");
var url=doc.getElementsByTagName("playurl")[0];
var json=JSON.parse(url.textContent);
list.some(function(type){
if(json.dispatch[type]){
var vlc=document.createElement("embed");
vlc.src=json.dispatch[type][0];
vlc.type="video/flv";
vlc.style.width="100%";
vlc.style.height="100%";
box.appendChild(vlc);
return true;
}
});
}
});
})(unsafeWindow.__INFO__.video.vid);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment