Skip to content

Commit b4dca9f

Browse files
author
wuwei
committed
Chrome插件发布
1 parent deeb32e commit b4dca9f

12 files changed

Lines changed: 273 additions & 83 deletions

File tree

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ http://www.56.com/u16/v_MTQ0Mjg2MjEz.html
1313
学习1分钟的就配置为2分钟的。
1414

1515

16+
Chrome插件配置的视频学习时间延时为30秒,请保证网速的情况下使用改插件。
17+
18+
1619
# 作业自动化
1720

1821
1、先调整到答案界面,控制台执行homework.js代码,打印出答案。
@@ -24,4 +27,6 @@ http://www.56.com/u16/v_MTQ0Mjg2MjEz.html
2427

2528
# 更新记录
2629

30+
2018-05-21 新增Chrome插件支持,打开视频界面可自动读取学习时间,自动定时学习。
31+
2732
2017-12-28 优化了更多题目结构支持。

StudyChromeApp/images/logo.png

24.2 KB
Loading

StudyChromeApp/js/script.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+

2+
// chrome.tabs.onUpdated.addListener(function(tabId,changeInfo,tab){
3+
// alert(tab.url);
4+
//
5+
//
6+
// })
7+
8+
9+
$(function(){
10+
11+
12+
$("#onlineStudy").click(function(){
13+
window.open('http://www.uestcedu.com/ifree/console/index.html');
14+
});
15+
16+
17+
18+
19+
$("#mybutton").click(function(){
20+
window.open('https://github.com/wuweiit/openLearningStudy');
21+
});
22+
23+
24+
25+
$("#site").click(function(){
26+
window.open('http://www.yl-blog.com/');
27+
});
28+
29+
30+
31+
});
32+

StudyChromeApp/manifest.json

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,29 @@
44
"version": "1.0",
55
"description":"自动学习",
66
"browser_action": {
7-
"default_icon": "1.png",
7+
"default_icon": "images/logo.png",
88
"default_popup": "popup.html"
99
},
1010
"content_scripts": [
1111
{
12-
"matches": ["http://learning.uestcedu.com/*","http://learning.uestcedu.com/*"],
13-
"js": ["jquery-1.4.3.min.js",
14-
15-
"script.js"],
16-
"run_at": "document_start"
12+
"matches": ["*://*/*","http://learning.uestcedu.com/*"],
13+
"js": ["lib/jquery-1.4.3.min.js", "script.js"],
14+
"run_at": "document_end"
15+
,
16+
"all_frames": true
1717
}
1818
],
19-
"permissions": ["*://*/*","tabs"]
19+
"permissions": [
20+
"tabs",
21+
"contextMenus", // 右键菜单
22+
"notifications", // 通知
23+
"webRequest", // web请求
24+
"webRequestBlocking",
25+
"storage", // 插件本地存储
26+
"http://*/*", // 可以通过executeScript或者insertCSS访问的网站
27+
"https://*/*" // 可以通过executeScript或者insertCSS访问的网站
28+
],
29+
30+
"homepage_url": "https://www.baidu.com"
31+
2032
}

StudyChromeApp/popup.html

Lines changed: 52 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,54 @@
11

2-
<style type="text/css">
3-
*{margin:0;padding:0;}
4-
body{color:#333;overflow: hidden;margin: 0px;padding:5px;background: white;font-size:12px;}
5-
img{margin:0 4px;}
6-
#addItemDiv{color:#ccc;}
7-
#taskItemList{ width:120px;}
8-
.hide{display:none;}
9-
.show{display:block;}
10-
.taskItem{cursor:pointer;}
11-
input{width:100%;}
12-
</style>
13-
<div id="taskItemList">
14-
<div id="taskItem" class="taskItem" onClick="autoStart()">
15-
<label class="on"></label><span class="taskTitle">开启自动学习</span>
2+
<!DOCTYPE html>
3+
<html lang="en">
4+
<head>
5+
<meta charset="UTF-8">
6+
<title>Title</title>
7+
8+
<script src="lib/jquery-1.4.3.min.js" type="text/javascript" ></script>
9+
<script src="js/script.js" type="text/javascript" ></script>
10+
11+
<style type="text/css">
12+
*{margin:0;padding:0;}
13+
body{color:#333;overflow: hidden;margin: 0px;padding:5px;background: white;font-size:12px;}
14+
img{margin:0 4px;}
15+
#addItemDiv{color:#ccc;}
16+
#taskItemList{ width:120px;}
17+
.hide{display:none;}
18+
.show{display:block;}
19+
.taskItem{
20+
cursor:pointer;
21+
height: 30px;
22+
line-height: 30px;
23+
padding: 0 10px;
24+
}
25+
.taskItem:hover{
26+
background: #d7d3d5;
27+
}
28+
.taskItem:hover > label{
29+
color: #ffffff;
30+
31+
}
32+
input{width:100%;}
33+
</style>
34+
</head>
35+
36+
37+
38+
39+
<body>
40+
41+
<div id="taskItemList">
42+
<div class="taskItem" id="onlineStudy">
43+
<label class="on"></label><span class="taskTitle">在线学习平台</span>
44+
</div>
45+
<div class="taskItem" id="mybutton">
46+
<label class="on"></label><span class="taskTitle">GitHub地址</span>
47+
</div>
48+
<div class="taskItem" id="site">
49+
<label class="on"></label><span class="taskTitle">作者:marker</span>
50+
</div>
1651
</div>
17-
</div>
52+
53+
</body>
54+
</html>

StudyChromeApp/popup.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+

2+
// chrome.tabs.onUpdated.addListener(function(tabId,changeInfo,tab){
3+
// alert(tab.url);
4+
//
5+
//
6+
// })
7+
8+
$("#mybutton").click(function(){
9+
10+
alert('==');
11+
})
12+
13+
14+
15+
function autoStart(){
16+
17+
alert(" dsad ");
18+
}
19+
20+
$(".taskItem").click(function(){
21+
22+
alert();
23+
});
24+
25+
26+
27+

StudyChromeApp/script.js

Lines changed: 110 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,112 @@
11

2-
chrome.tabs.onUpdated.addListener(function(tabId,changeInfo,tab){
3-
alert(tab.url);
4-
})
5-
6-
7-
function autoStart(){
8-
9-
alert(" dsad ");
2+
3+
var delayTime = 30;// 秒
4+
5+
var els = $("#btnNext");
6+
if(els.length > 0){
7+
8+
console.log("找到了下一个按钮!");
9+
10+
// startStudy();
11+
12+
setTimeout(function(){
13+
14+
var time = getTime();
15+
startStudy(time);
16+
17+
18+
}, 1000);
19+
}
20+
21+
22+
/**
23+
* 获取学习时间
24+
*/
25+
function getTime(){
26+
27+
var text = $(window.parent["w_lms_content"].document).find("#tdRemark").text();
28+
var start = text.indexOf('最少要求学习');
29+
var end = text.indexOf('秒');
30+
31+
var time = parseInt(text.substring(start+6, end ));
32+
33+
console.log("读取到视频的学习时间为:" + time);
34+
35+
return time;
36+
}
37+
38+
39+
/**
40+
* 开始学习
41+
* @param time
42+
*/
43+
function startStudy(time) {
44+
45+
/**
46+
* 该自动学习脚本仅用于学习研究,未经作者同意不得用于商业用途。
47+
*
48+
* @author marker
49+
* @date 2017-03-05
50+
* @type {number}
51+
*/
52+
53+
/* 全局变量配置 */
54+
var STUDY_DELAY_TIME = 1; // 延时启动。单位:秒
55+
var STUDY_PERIOD_TIME = time + delayTime; // 下一章节周期 单位:秒
56+
57+
58+
59+
/**
60+
* 自动学习函数
61+
*/
62+
var myInterval;
63+
function study(){
64+
console.log("学习完成,准备下一章节...")
65+
console.log(window.JQUERY_CUSTERM );
66+
// 10秒后开始
67+
if(window.JQUERY_CUSTERM ("#btnNext")){
68+
console.log("进入下一章节...")
69+
window.JQUERY_CUSTERM("#btnNext").click();
70+
71+
// 清楚定时任务
72+
clearTimeout(myInterval);
73+
74+
75+
setTimeout(function(){
76+
77+
// 获取当前课程需要的时间
78+
STUDY_PERIOD_TIME = getTime() + delayTime;
79+
80+
81+
startRun();
82+
83+
84+
}, 1000);
85+
86+
87+
}else{
88+
console.error("没有找到【下一个】按钮");
89+
console.log("正在关闭周期循环管理器!");
90+
clearTimeout(myInterval);
91+
}
92+
};
93+
94+
95+
function startRun(){
96+
console.log("【下一个】按钮获取焦点")
97+
window.JQUERY_CUSTERM("#btnNext", window.frames['w_main']).focus();
98+
myInterval = setTimeout(study, STUDY_PERIOD_TIME * 1000);
99+
}
100+
101+
102+
window.JQUERY_CUSTERM = $;
103+
console.log("自动学习脚本启动...");
104+
105+
106+
setTimeout(startRun, STUDY_DELAY_TIME * 1000);
107+
108+
109+
10110
}
11-
$(function(){
12-
13-
14-
15-
16-
$("#taskItem").click(function(){
17-
18-
alert();
19-
});
20-
21-
22-
23-
})
24-
console.log($("#tdRemark").text());
25-
26-
if($("#tdRemark").text().indexOf("已经学习完毕") != -1){
27-
alert("学习完成了的哈@");
28-
}
111+
112+

StudyChromeApp/study.js

Lines changed: 0 additions & 12 deletions
This file was deleted.

dist/v0.0.1/StudyChromeApp.crx

57.3 KB
Binary file not shown.

0 commit comments

Comments
 (0)