Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
东方怂天
cxmooc-tools
提交
13820888
C
cxmooc-tools
项目概览
东方怂天
/
cxmooc-tools
通知
11
Star
1
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
cxmooc-tools
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
13820888
编写于
6月 12, 2018
作者:
C
CodFrm
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
视频 题目 自动挂机
上级
97bd32e4
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
152 addition
and
46 deletion
+152
-46
src/cxmooc-tools/action.js
src/cxmooc-tools/action.js
+27
-20
src/cxmooc-tools/common.js
src/cxmooc-tools/common.js
+54
-4
src/cxmooc-tools/popup.html
src/cxmooc-tools/popup.html
+2
-1
src/cxmooc-tools/popup.js
src/cxmooc-tools/popup.js
+0
-1
src/cxmooc-tools/topic.js
src/cxmooc-tools/topic.js
+47
-0
src/cxmooc-tools/video.js
src/cxmooc-tools/video.js
+22
-20
未找到文件。
src/cxmooc-tools/action.js
浏览文件 @
13820888
...
...
@@ -6,28 +6,35 @@ const moocConfig = require('../config');
* 开始监控暂停,自动重新播放
*/
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
();
var
timer
=
setInterval
(
function
()
{
var
player
=
document
.
querySelector
(
'
object
'
);
if
(
player
!=
undefined
)
{
clearInterval
(
timer
);
}
else
{
return
;
}
});
function
play
()
{
var
time
=
setInterval
(
function
()
{
if
(
player
.
getPlayState
()
!=
1
)
{
player
.
playMovie
();
}
else
{
clearInterval
(
time
);
var
reader
=
player
.
parentNode
.
parentNode
;
play
();
$
(
reader
).
bind
(
'
onPause
'
,
function
(
h
,
g
)
{
play
();
});
//监听完成事件
$
(
reader
).
bind
(
'
onEnd
'
,
function
(
h
,
g
)
{
if
(
playOver
!=
undefined
)
{
playOver
();
}
},
1000
);
}
});
function
play
()
{
var
time
=
setInterval
(
function
()
{
if
(
player
.
getPlayState
()
!=
1
)
{
player
.
playMovie
();
}
else
{
clearInterval
(
time
);
}
},
1000
);
}
},
200
);
}
window
.
removeOldPlayer
=
function
(
obj
)
{
...
...
src/cxmooc-tools/common.js
浏览文件 @
13820888
...
...
@@ -6,6 +6,15 @@ const video = require('./video');
*/
export
function
showExpand
(
_this
)
{
var
ans
=
_this
.
contentDocument
.
getElementsByClassName
(
'
ans-job-icon
'
);
var
config
=
JSON
.
parse
(
localStorage
[
'
config
'
]);
if
(
ans
.
length
<=
0
&&
config
[
'
auto
'
])
{
//没有任务点,正在挂机的状态,5s后切换下一个
console
.
log
(
'
null,switch task
'
);
setTimeout
(
function
()
{
switchTask
();
},
5000
);
return
;
}
for
(
var
i
=
0
;
i
<
ans
.
length
;
i
++
)
{
ans
[
i
].
style
.
width
=
'
100%
'
;
ans
[
i
].
style
.
textAlign
=
'
center
'
;
...
...
@@ -19,6 +28,10 @@ export function showExpand(_this) {
//未做完的题目
topic
(
_this
,
ans
[
i
],
i
,
false
);
}
//如果是挂机模式,并且是第一个,点击,启动!
if
(
i
==
0
&&
config
[
'
auto
'
])
{
_this
.
contentDocument
.
getElementById
(
'
action-btn
'
).
click
();
}
}
}
...
...
@@ -110,12 +123,49 @@ export function switchChoice() {
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
)
{
var
tabs
=
tab
[
0
].
getElementsByTagName
(
'
span
'
);
for
(
var
i
=
0
;
i
<
tabs
.
length
;
i
++
)
{
if
(
tabs
[
i
].
className
.
indexOf
(
'
currents
'
)
>
0
)
{
//现行,切换到下一个
if
(
i
+
1
>=
tabs
.
length
)
{
//超过长度
break
;
}
else
{
return
tabs
[
i
+
1
];
}
}
}
//可以换页了
console
.
log
(
tabs
);
return
false
;
}
export
function
switchTask
()
{
//判断选项夹
var
tab
=
switchChoice
();
if
(
tab
!==
false
)
{
tab
.
click
();
return
true
;
}
//判断任务点
var
course
=
document
.
getElementById
(
'
coursetree
'
);
var
now
=
course
.
getElementsByClassName
(
'
currents
'
);
if
(
now
.
length
<=
0
)
{
alert
(
'
很奇怪啊
'
);
return
false
;
}
now
=
now
[
0
];
var
next
=
now
.
parentNode
.
parentNode
;
if
(
next
.
nextElementSibling
==
undefined
)
{
if
(
next
.
parentNode
.
nextElementSibling
==
undefined
)
{
alert
(
'
挂机完成了
'
);
return
true
;
}
else
{
next
=
next
.
parentNode
;
}
}
console
.
log
(
next
);
//两个父节点后,下一个兄弟节点的第一个节点,点击,启动!
next
.
nextElementSibling
.
getElementsByTagName
(
'
a
'
)[
0
].
click
();
console
.
log
(
'
next task
'
);
return
true
;
}
\ No newline at end of file
src/cxmooc-tools/popup.html
浏览文件 @
13820888
...
...
@@ -55,7 +55,7 @@
</div>
<div
class=
"config-item"
>
<input
type=
"checkbox"
id=
"auto"
/>
<label
for=
"auto"
title=
"
点开始挂机,播放完一个视频之后会自动进入
下一个"
>
全自动挂机
</label>
<label
for=
"auto"
title=
"
进入一个页面就会自动开始挂机,完成一个任务之后会自动进行
下一个"
>
全自动挂机
</label>
</div>
<div
id=
"auto-m"
class=
"config-item"
style=
"display: none;"
>
<label
for=
"interval"
title=
"播放(题目)完成后n分钟再继续下一个任务"
>
间隔时间:
</label>
...
...
@@ -64,6 +64,7 @@
</div>
<div>
<h4>
其他说明:
</h4>
<p>
1.4之后采用了修改的播放器,需要能够从服务器下载才能使用全自动挂机
</p>
<p>
GitHub开源地址:
<br>
<a
href=
"https://github.com/CodFrm/cxmooc-tools"
target=
"_black"
>
https://github.com/CodFrm/cxmooc-tools
</a>
...
...
src/cxmooc-tools/popup.js
浏览文件 @
13820888
...
...
@@ -43,7 +43,6 @@ window.onload = function () {
chrome
.
storage
.
sync
.
set
({
'
auto
'
:
check
.
checked
});
document
.
getElementById
(
'
version
'
).
innerHTML
=
check
.
checked
;
}
document
.
getElementById
(
'
interval
'
).
onblur
=
function
()
{
chrome
.
storage
.
sync
.
set
({
...
...
src/cxmooc-tools/topic.js
浏览文件 @
13820888
...
...
@@ -9,11 +9,22 @@ module.exports = function (_this, elLogo, index, over) {
var
topicDoc
=
doc
.
getElementById
(
'
frame_content
'
).
contentDocument
;
if
(
over
)
{
//完成的提交答案
var
auto
=
common
.
createBtn
(
'
下一个
'
);
auto
.
id
=
'
action-btn
'
;
elLogo
.
appendChild
(
auto
);
auto
.
onclick
=
function
()
{
//进入下一个
setTimeout
(
function
()
{
nextTask
();
},
4000
);
}
dealDocumentTopic
(
topicDoc
);
}
else
{
//未完成的填入答案
var
auto
=
common
.
createBtn
(
'
搜索答案
'
);
auto
.
id
=
'
action-btn
'
;
elLogo
.
appendChild
(
auto
);
var
config
=
JSON
.
parse
(
localStorage
[
'
config
'
]);
auto
.
onclick
=
function
()
{
var
topicList
=
topicDoc
.
getElementsByClassName
(
'
Zy_TItle
'
);
var
topic
=
[];
...
...
@@ -37,12 +48,48 @@ module.exports = function (_this, elLogo, index, over) {
for
(
let
i
in
json
)
{
fillIn
(
json
[
i
].
topic
,
json
[
i
].
result
==
undefined
?
[]
:
json
[
i
].
result
);
}
//如果是自动挂机,填入之后自动提交
if
(
!
config
[
'
auto
'
])
{
return
;
}
setTimeout
(
function
()
{
//提交操作
var
submit
=
topicDoc
.
getElementsByClassName
(
'
Btn_blue_1
'
);
submit
=
submit
[
0
];
submit
.
click
();
//判断有没有未填的题目
setTimeout
(
function
()
{
if
(
topicDoc
.
getElementById
(
'
tipContent
'
).
innerText
.
indexOf
(
'
未做完
'
)
>
0
)
{
alert
(
'
提示:
'
+
topicDoc
.
getElementById
(
'
tipContent
'
).
innerText
);
return
;
}
//确定提交
var
submit
=
topicDoc
.
getElementsByClassName
(
'
bluebtn
'
);
submit
[
0
].
click
();
setTimeout
(
function
()
{
doc
.
getElementById
(
'
frame_content
'
).
contentWindow
.
location
.
reload
();
},
2000
);
},
1000
);
},
config
[
'
interval
'
]
*
1000
*
60
);
}
}
}
}
}
function
nextTask
()
{
//判断有没有下一个,自动进行下一个任务
var
ans
=
_this
.
contentDocument
.
getElementsByClassName
(
'
ans-job-icon
'
);
if
(
ans
.
length
>
index
+
1
)
{
//点击
var
nextAction
=
ans
[
index
+
1
].
firstElementChild
;
nextAction
.
click
();
}
else
{
//已经是最后一个,切换任务
common
.
switchTask
();
}
}
/**
* 用document方式提取题目
*/
...
...
src/cxmooc-tools/video.js
浏览文件 @
13820888
...
...
@@ -10,7 +10,6 @@ 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
;
...
...
@@ -41,25 +40,28 @@ module.exports = function (_this, elLogo, index) {
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
);
});
var
timer
=
setInterval
(
function
()
{
if
(
wid
.
monitorPlay
!=
undefined
)
{
clearInterval
(
timer
);
wid
.
monitorPlay
(
function
()
{
//播放完成
console
.
log
(
'
over
'
);
setTimeout
(
function
()
{
//判断有没有下一个,自动进行下一个任务
var
ans
=
_this
.
contentDocument
.
getElementsByClassName
(
'
ans-job-icon
'
);
if
(
ans
.
length
>
index
+
1
)
{
//点击
var
nextAction
=
ans
[
index
+
1
].
firstElementChild
;
nextAction
.
click
();
}
else
{
//已经是最后一个,切换任务
common
.
switchTask
();
}
},
config
[
'
interval
'
]
*
1000
*
60
);
});
}
},
1000
);
}
else
{
wid
.
monitorPlay
();
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录