1 |
- $(function(){var e={checkPc:function(){return/Android|webOS|iPhone|Windows Phone|iPod|BlackBerry|SymbianOS/i.test(window.navigator.userAgent)&&!/[\?&]pc(?:[=&].*|$)/.test(window.location.href)?!1:!0},getParam:function(e){var i=document.location.hash.substr(2),t=this.getParam2(e,i);return null==t&&(i=document.location.search.substr(1),t=this.getParam2(e,i)),t},getParam2:function(e,i){var t=new RegExp("(;|^|!|&|\\?)"+e+"=([^&]*)(&|$)");if(r=i.match(t),null!=r)try{return decodeURIComponent(r[2])}catch(n){return null}return null}},i={isWap:/Android|webOS|iPhone|Windows Phone|iPod|BlackBerry|SymbianOS/i.test(window.navigator.userAgent),exid:e.getParam("exid"),isPc:e.checkPc(),$dwExternalVideo:$(".dw-external-video"),$dwExternalVideoLen:0,frameClicked:[],frameSkipWap:[],frameClickedNum:0,interval:null,init:function(){var e=this;this.$dwExternalVideoLen=this.$dwExternalVideo&&this.$dwExternalVideo.length||0,this.$dwExternalVideoLen&&(this.initCss(),this.$dwExternalVideo.each(function(i,t){e.renderVideo(t,i)}),this.initEvent())},initEvent:function(){var e=this;this.interval=setInterval(function(){e.checkIframeClick()},200)},initCss:function(){var e=this.isPc?"width: 100%;padding-bottom: 63%;":"width: 100%;padding-bottom: 56%;",i=this.isPc?"width: 50%;padding-bottom: 84%;":"width: 66%;padding-bottom: 105%;",t=".dw-external-video{position: relative;height: 0;margin: 1.5em auto 0;background: #000;z-index: 0;} .dw-external-video.v-horizontal {"+e+"} .dw-external-video.v-vertical {"+i+"} .dw-external-video.v-horizontal iframe,.dw-external-video.v-vertical iframe,.dw-external-video.v-horizontal embed,.dw-external-video.v-vertical embed{position: absolute;width: 100%;height: 100%;z-index: 1;}";$("head").append("<style>"+t+"</style>")},checkIframeClick:function(){for(var e=document.activeElement,i=0;i<this.$dwExternalVideoLen;i++){var t=document.getElementById("externalVideo"+i);e!==t||this.frameClicked[i]||(this.frameClicked[i]=!0,++this.frameClickedNum,this.reportVideo(2),this.isPc?clearInterval(this.interval):this.frameSkipWap[i]&&(location.href=this.frameSkipWap[i]))}},renderVideo:function(e,i){var t=$(e),n=t.find("a"),r=[],a=!0,o=t.html();n.each(function(e,i){r.push($(i).attr("href"))});var d=r[0],l=r[1]||d,s=this.isPc?d:l,h=this.getWapSkipUrl(s),c=/<embed.+?>/gi.test(o);c&&this.isWap?s=this.checkNeedIframe(o)||s:c&&!this.isWap&&(a=!1),a?t.html('<iframe id="externalVideo'+i+'" src="'+s+'" frameborder="0"></iframe>'):c&&!this.isWap?t.find("embed").eq(0).attr("id","externalVideo"+i):this.isWap&&t.html('<p style="position: absolute;top: 50%;width: 100%;color: #FFF;text-align: center;font-size: 12px;margin-top: 0;transform: translateY(-50%);">视频暂时无法播放哦O.O</p>'),this.frameClicked.push(!1),this.frameSkipWap.push(h),this.reportVideo(1)},checkNeedIframe:function(i){if(!i)return!1;var t=/huya.com/.test(i);if(t){var n=e.getParam2("vid",i);return"http://v.huya.com/m/play/"+n+".html"}return!1},getWapSkipUrl:function(i){if(i){var t=/player.bilibili.com/.test(i);return t?"https://www.bilibili.com/video/av"+e.getParam2("aid",i)+"/?zw":""}},reportVideo:function(e){var i=new Image,t=e&&1!=e?"play":"load",n="";n=this.exid?"//video.duowan.com/exvrp/"+t+"/"+this.exid+".webp":"//video.duowan.com/exvrp/"+t+".webp",i.src=n,i=null}};i.init()});
|