提交 97bd32e4 编写于 作者: C CodFrm

播放完成监控

上级 83353f89
......@@ -5,13 +5,19 @@ const moocConfig = require('../config');
/**
* 开始监控暂停,自动重新播放
*/
window.monitorPlay = function () {
window.monitorPlay = function (playOver) {
var player = document.querySelector('object');
var reader = player.parentNode.parentNode;
play();
$(reader).bind('onPause', function (h, g) {
play();
});
//监听完成事件
$(reader).bind('onEnd', function (h, g) {
if (playOver != undefined) {
playOver();
}
});
function play() {
var time = setInterval(function () {
......
const topic = require('./topic');
const video=require('./video');
const video = require('./video');
/**
* 显示扩展按钮,并绑定事件
* @param {iframe document} _this
......@@ -103,4 +103,19 @@ export function createBtn(title) {
btn.style.boxShadow = '';
};
return btn;
}
export function switchChoice() {
var tab = document.getElementsByClassName('tabtags');
if (tab.length <= 0) {
return false;
}
var tabs=tab[0].getElementsByTagName('span');
for(var i=0;i<tabs.length;i++){
if(tabs[i].className.indexOf('currents')>0){
//现行,切换到下一个
}
}
//可以换页了
console.log(tabs);
}
\ No newline at end of file
......@@ -12,9 +12,10 @@ window.onload = function () {
}
injected(document, 'mooc.js');
document.head.setAttribute('chrome-url', chrome.extension.getURL(''));
chrome.storage.sync.get('rand_answer', function (items) {
chrome.storage.sync.get(['rand_answer','interval','auto'], function (items) {
//设置一下配置
document.head.setAttribute('rand-answer', items.rand_answer);
localStorage['config'] =JSON.stringify(items);
});
})
}
......
......@@ -10,6 +10,7 @@ const get = common.get;
* @param {*} index
*/
module.exports = function (_this, elLogo, index) {
common.switchChoice();
//获取要操作的对象和视频id
var wid = _this.contentDocument.getElementsByTagName('iframe')[index].contentWindow;
var doc = _this.contentDocument.getElementsByTagName('iframe')[index].contentDocument;
......@@ -31,11 +32,37 @@ module.exports = function (_this, elLogo, index) {
}, 1000);
//创建各个按钮
var hang_btn = createBtn('开始挂机');
hang_btn.id = 'action-btn';
hang_btn.value = index;
hang_btn.title = "直接开始";
elLogo.appendChild(hang_btn);
hang_btn.onclick = function () {
wid.monitorPlay();
var config = JSON.parse(localStorage['config']);
if (config['auto']) {
//全自动挂机开始
hang_btn.innerText = '挂机中...';
wid.monitorPlay(function () {
//播放完成
console.log('over');
setTimeout(function () {
//判断有没有下一个,自动进行下一个任务
var ans = _this.contentDocument.getElementsByClassName('ans-job-icon');
if (ans.length > index + 1) {
//点击
console.log('下一任务点');
console.log(ans[index + 1]);
var nextAction = ans[index + 1].firstElementChild;
console.log(nextAction);
nextAction.click();
} else {
//已经是最后一个,搜索下一个选项夹
console.log('下一选项夹');
}
}, config['interval'] * 1000 * 60);
});
} else {
wid.monitorPlay();
}
}
// var hang_mode_2 = createBtn('挂机模式2(bate)');
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册