forked from Eanya-Tonic/CCTV_Viewer
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
添加节目单功能,按菜单键即可呼出
- Loading branch information
Showing
17 changed files
with
857 additions
and
368 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
function simulate(element, eventName) { | ||
var options = extend(defaultOptions, arguments[2] || {}); | ||
var oEvent, eventType = null; | ||
|
||
for (var name in eventMatchers) { | ||
if (eventMatchers[name].test(eventName)) { | ||
eventType = name; | ||
break; | ||
} | ||
} | ||
|
||
if (!eventType) throw new SyntaxError('Only HTMLEvents and MouseEvents interfaces are supported'); | ||
|
||
if (document.createEvent) { | ||
oEvent = document.createEvent(eventType); | ||
if (eventType == 'HTMLEvents') { | ||
oEvent.initEvent(eventName, options.bubbles, options.cancelable); | ||
} else { | ||
oEvent.initMouseEvent(eventName, options.bubbles, options.cancelable, document.defaultView, options.button, options.pointerX, options.pointerY, options.pointerX, options.pointerY, options.ctrlKey, options.altKey, options.shiftKey, options.metaKey, options.button, element); | ||
} | ||
element.dispatchEvent(oEvent); | ||
} else { | ||
options.clientX = options.pointerX; | ||
options.clientY = options.pointerY; | ||
var evt = document.createEventObject(); | ||
oEvent = extend(evt, options); | ||
element.fireEvent('on' + eventName, oEvent); | ||
} | ||
return element; | ||
} | ||
|
||
function extend(destination, source) { | ||
for (var property in source) destination[property] = source[property]; | ||
return destination; | ||
} | ||
|
||
var eventMatchers = { | ||
'HTMLEvents': /^(?:load|unload|abort|error|select|change|submit|reset|focus|blur|resize|scroll)$/, | ||
'MouseEvents': /^(?:click|dblclick|mouse(?:down|up|over|move|out))$/ | ||
} | ||
var defaultOptions = { | ||
pointerX: 0, | ||
pointerY: 0, | ||
button: 0, | ||
ctrlKey: false, | ||
altKey: false, | ||
shiftKey: false, | ||
metaKey: false, | ||
bubbles: true, | ||
cancelable: true | ||
} | ||
|
||
function triggerMouseEvent (node, eventType) { | ||
var clickEvent = document.createEvent ('MouseEvents'); | ||
clickEvent.initEvent (eventType, true, true); | ||
node.dispatchEvent (clickEvent); | ||
}; | ||
|
||
function mouseDragStart(node) { | ||
console.log("Starting drag..."); | ||
console.log(node.offsetTop); | ||
console.log(node.offsetLeft); | ||
triggerMouseEvent(node, "mousedown") | ||
} | ||
|
||
function mouseDragEnd(node){ | ||
console.log("Ending drag..."); | ||
const rect = node.getBoundingClientRect(); | ||
document.querySelector("#epg_right_shift_player").click() | ||
simulate(node, "mousemove" , {pointerX: rect.x-3 , pointerY: node.offsetTop}) | ||
simulate(node, "mouseup" , {pointerX: rect.x-3, pointerY: node.offsetTop}) | ||
} | ||
function sleep1(time) { | ||
time*=1000 | ||
return new Promise(resolve => { | ||
setTimeout(() => { | ||
resolve(); | ||
}, time); | ||
}); | ||
} | ||
|
||
async function playback(){ | ||
if(document.querySelector("#play_or_pause_play_player").style.display==="none"){ | ||
document.querySelector("#play_or_plause_player").click() | ||
} | ||
await sleep1(3) | ||
const targetElement = document.querySelector("#timeshift_pointer_player") | ||
mouseDragStart(targetElement); | ||
mouseDragEnd(targetElement); | ||
}; | ||
|
||
playback() | ||
console.log('执行了回退'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// 定义休眠函数 | ||
function sleep(ms) { | ||
return new Promise(resolve => setTimeout(resolve, ms)); | ||
} | ||
|
||
// 页面加载完成后执行 JavaScript 脚本 | ||
let interval = setInterval(async function executeScript() { | ||
console.log('页面加载完成!'); | ||
|
||
// 休眠 1000 毫秒(1秒) | ||
await sleep(1000); | ||
|
||
// 休眠 50 毫秒 | ||
await sleep(50); | ||
|
||
console.log('点击分辨率按钮'); | ||
var elem = document.querySelector('#resolution_item_720_player'); | ||
elem.click(); | ||
|
||
// 休眠 50 毫秒 | ||
await sleep(50); | ||
|
||
console.log('设置音量并点击音量按钮'); | ||
var btn = document.querySelector('#player_sound_btn_player'); | ||
btn.setAttribute('volume', 100); | ||
btn.click(); | ||
btn.click(); | ||
btn.click(); | ||
|
||
// 休眠 50 毫秒 | ||
await sleep(50); | ||
|
||
console.log('点击全屏按钮'); | ||
var fullscreenBtn = document.querySelector('#player_pagefullscreen_yes_player'); | ||
fullscreenBtn.click(); | ||
clearInterval(interval); | ||
}, 3000); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
function simulate(element, eventName) { | ||
var options = extend(defaultOptions, arguments[2] || {}); | ||
var oEvent, eventType = null; | ||
|
||
for (var name in eventMatchers) { | ||
if (eventMatchers[name].test(eventName)) { | ||
eventType = name; | ||
break; | ||
} | ||
} | ||
|
||
if (!eventType) throw new SyntaxError('Only HTMLEvents and MouseEvents interfaces are supported'); | ||
|
||
if (document.createEvent) { | ||
oEvent = document.createEvent(eventType); | ||
if (eventType == 'HTMLEvents') { | ||
oEvent.initEvent(eventName, options.bubbles, options.cancelable); | ||
} else { | ||
oEvent.initMouseEvent(eventName, options.bubbles, options.cancelable, document.defaultView, options.button, options.pointerX, options.pointerY, options.pointerX, options.pointerY, options.ctrlKey, options.altKey, options.shiftKey, options.metaKey, options.button, element); | ||
} | ||
element.dispatchEvent(oEvent); | ||
} else { | ||
options.clientX = options.pointerX; | ||
options.clientY = options.pointerY; | ||
var evt = document.createEventObject(); | ||
oEvent = extend(evt, options); | ||
element.fireEvent('on' + eventName, oEvent); | ||
} | ||
return element; | ||
} | ||
|
||
function extend(destination, source) { | ||
for (var property in source) destination[property] = source[property]; | ||
return destination; | ||
} | ||
|
||
var eventMatchers = { | ||
'HTMLEvents': /^(?:load|unload|abort|error|select|change|submit|reset|focus|blur|resize|scroll)$/, | ||
'MouseEvents': /^(?:click|dblclick|mouse(?:down|up|over|move|out))$/ | ||
} | ||
var defaultOptions = { | ||
pointerX: 0, | ||
pointerY: 0, | ||
button: 0, | ||
ctrlKey: false, | ||
altKey: false, | ||
shiftKey: false, | ||
metaKey: false, | ||
bubbles: true, | ||
cancelable: true | ||
} | ||
|
||
function triggerMouseEvent (node, eventType) { | ||
var clickEvent = document.createEvent ('MouseEvents'); | ||
clickEvent.initEvent (eventType, true, true); | ||
node.dispatchEvent (clickEvent); | ||
}; | ||
|
||
function mouseDragStart(node) { | ||
console.log("Starting drag..."); | ||
console.log(node.offsetTop); | ||
console.log(node.offsetLeft); | ||
triggerMouseEvent(node, "mousedown") | ||
} | ||
|
||
function mouseDragEnd(node){ | ||
console.log("Ending drag..."); | ||
const rect = node.getBoundingClientRect(); | ||
document.querySelector("#epg_right_shift_player").click() | ||
simulate(node, "mousemove" , {pointerX: rect.x+20 , pointerY: node.offsetTop}) | ||
simulate(node, "mouseup" , {pointerX: rect.x+20, pointerY: node.offsetTop}) | ||
} | ||
function sleep1(time) { | ||
time*=1000 | ||
return new Promise(resolve => { | ||
setTimeout(() => { | ||
resolve(); | ||
}, time); | ||
}); | ||
} | ||
|
||
async function playback(){ | ||
if(document.querySelector("#play_or_pause_play_player").style.display==="none"){ | ||
document.querySelector("#play_or_plause_player").click() | ||
} | ||
await sleep1(3) | ||
const targetElement = document.querySelector("#timeshift_pointer_player") | ||
mouseDragStart(targetElement); | ||
mouseDragEnd(targetElement); | ||
}; | ||
|
||
playback() | ||
console.log('执行了前进'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{ | ||
// 定义休眠函数 | ||
function sleep(ms) { | ||
return new Promise(resolve => setTimeout(resolve, ms)); | ||
} | ||
|
||
// 页面加载完成后执行 JavaScript 脚本 | ||
let interval = setInterval(async function executeScript() { | ||
console.log('页面加载完成!'); | ||
|
||
// 休眠 1000 毫秒(1秒) | ||
await sleep(1000); | ||
|
||
// 休眠 50 毫秒 | ||
await sleep(50); | ||
|
||
console.log('点击分辨率按钮'); | ||
var elem = document.querySelector('#resolution_item_720_player'); | ||
elem.click(); | ||
|
||
// 休眠 50 毫秒 | ||
await sleep(50); | ||
|
||
console.log('设置音量并点击音量按钮'); | ||
var btn = document.querySelector('#player_sound_btn_player'); | ||
btn.setAttribute('volume', 100); | ||
btn.click(); | ||
btn.click(); | ||
btn.click(); | ||
|
||
// 休眠 50 毫秒 | ||
await sleep(50); | ||
|
||
console.log('点击全屏按钮'); | ||
var fullscreenBtn = document.querySelector('#player_pagefullscreen_yes_player'); | ||
fullscreenBtn.click(); | ||
clearInterval(interval); | ||
}, 3000); | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.