mirror of
https://github.com/hxh19950701/WebViewTvLive.git
synced 2026-04-26 01:16:12 +03:00
[GH-ISSUE #72] 央視網央視頻webview,js #59
Labels
No labels
bug
duplicate
enhancement
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/WebViewTvLive-hxh19950701#59
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @nt2020xp on GitHub (Apr 11, 2025).
Original GitHub issue: https://github.com/hxh19950701/WebViewTvLive/issues/72
function main(item) {
let url = item.url;
let id = ku9.getQuery(url, "id");
let domain = id.split('/');
let headers;
if (domain[2] === 'http://tv.cctv.com' || domain[2] === 'http://www.yangshipin.cn') { // 使用 || 合并条件,
headers = {
'User-Agent': 'Mozilla/5.0 (Linux; Android 10; HMA-AL00 Build/HUAWEIHMA-AL00; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/88.0.4324.93 Mobile Safari/537.36'
};
}else{
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36'
};
}
const jscode=
(function(){const startTime=Date.now();document.documentElement.style.backgroundColor='black';document.documentElement.style.height='10%';document.documentElement.style.margin='0';document.documentElement.style.padding='0';document.body.style.visibility='hidden';document.body.style.margin='0';document.body.style.padding='0';document.body.style.minHeight='10vh';function getVideoParentShadowRoots(){const allElements=document.querySelectorAll('*');for(const element of allElements){const shadowRoot=element.shadowRoot;if(shadowRoot){const video=shadowRoot.querySelector('video');if(video)return video}}return null}function removeControls(){['#control_bar','.controls','.vjs-control-bar','xg-controls'].forEach(selector=>{document.querySelectorAll(selector).forEach(e=>e.remove())})}function setupVideo(video){const container=document.createElement('div');container.style.position='fixed';container.style.top='0';container.style.left='0';container.style.width='100vw';container.style.height='100vh';container.style.zIndex='2147483647';container.style.backgroundColor='black';video.style.width='100%';video.style.height='100%';video.style.objectFit='fill';video.style.transform='translateZ(0)';container.appendChild(video);document.body.appendChild(container);document.body.style.overflow='hidden';document.documentElement.style.overflow='hidden';const enterFullscreen=()=>{if(container.requestFullscreen){container.requestFullscreen()}else if(container.webkitRequestFullscreen){container.webkitRequestFullscreen()}const fullscreenStyle=()=>{video.style.objectFit='contain';container.style.width='100%';container.style.height='100%'};container.addEventListener('fullscreenchange',fullscreenStyle);video.muted=false;video.volume=1;video.playsInline=false;video.setAttribute('playsinline','false');try{video.play()}catch(e){video.muted=true;video.play()}};setTimeout(enterFullscreen,300)}function checkVideo(){if(Date.now()-startTime>15000){clearInterval(interval);document.body.style.visibility='visible';document.documentElement.style.visibility='visible';return}let video=document.querySelector('video')||getVideoParentShadowRoots();if(video&&video.readyState>0){clearInterval(interval);removeControls();setupVideo(video);if(video.requestFullscreen){video.requestFullscreen()}else if(video.webkitRequestFullscreen){video.webkitRequestFullscreen()}document.body.style.visibility='visible';document.documentElement.style.visibility='visible'}}const interval=setInterval(checkVideo,100)})();;return {
webview: id,
headers :headers,
jscode: jscode
};
}
@hxh19950701 commented on GitHub (Apr 11, 2025):
你的想法是什么?