Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
东方怂天
cxmooc-tools
提交
57963777
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 搜索 >>
提交
57963777
编写于
6月 21, 2018
作者:
C
CodFrm
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
本地题库导入&检索
上级
ae8f4a3b
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
113 addition
and
7 deletion
+113
-7
src/cxmooc-tools/common.js
src/cxmooc-tools/common.js
+6
-0
src/cxmooc-tools/import.html
src/cxmooc-tools/import.html
+50
-1
src/cxmooc-tools/import.js
src/cxmooc-tools/import.js
+32
-0
src/cxmooc-tools/popup.html
src/cxmooc-tools/popup.html
+2
-0
src/cxmooc-tools/start.js
src/cxmooc-tools/start.js
+19
-3
webpack.config.js
webpack.config.js
+4
-3
未找到文件。
src/cxmooc-tools/common.js
浏览文件 @
57963777
...
...
@@ -181,4 +181,10 @@ export function switchTask() {
next
.
nextElementSibling
.
getElementsByTagName
(
'
a
'
)[
0
].
firstElementChild
.
className
=
'
currents
'
;
console
.
log
(
'
next task
'
);
return
true
;
}
export
function
dealRegx
(
str
,
topic
)
{
str
=
str
.
replace
(
'
{topic}
'
,
'
[
\\
s
\\
S]*?
'
+
topic
+
'
[
\\
s
\\
S]*?
'
);
str
=
str
.
replace
(
'
{answer}
'
,
'
(
\\
S+?)
'
);
return
str
;
}
\ No newline at end of file
src/cxmooc-tools/import.html
浏览文件 @
57963777
...
...
@@ -9,7 +9,56 @@
<
%=
htmlWebpackPlugin.options.title
%
>
</title>
</head>
<style>
body
{
padding
:
0
20%
;
}
h4
{
margin
:
8px
0
;
}
.content
{
width
:
100%
;
min-height
:
400px
;
padding
:
4px
8px
;
font-size
:
14px
;
}
.bor
{
box-sizing
:
border-box
;
outline
:
none
;
border
:
1px
solid
#eee
;
}
.bor
:focus
,
.bor
:hover
{
border
:
1px
solid
#a5d7ff
;
}
.ipt-text
{
padding
:
4px
;
width
:
100%
;
font-size
:
14px
;
}
.sub-btn
{
margin-left
:
calc
(
100%
-
80px
);
width
:
80px
;
margin-top
:
8px
;
}
</style>
<body>
<h4>
题库内容:
</h4>
<textarea
id=
"content"
class=
"content bor"
></textarea>
<br>
<input
id=
"regx"
class=
"ipt-text bor"
type=
"text"
value=
""
placeholder=
"正则表达式,题目用 {topic} 代替"
>
<button
id=
"submit"
class=
"sub-btn"
>
确定
</button>
<h4>
匹配测试
</h4>
<input
id=
"topic"
class=
"ipt-text bor"
type=
"text"
value=
""
placeholder=
"题目标题"
>
<button
id=
"test"
class=
"sub-btn"
>
测试
</button>
<div
id=
"result"
style=
"width: 100%;"
>
结果
</div>
</body>
</html>
\ No newline at end of file
src/cxmooc-tools/import.js
0 → 100644
浏览文件 @
57963777
const
common
=
require
(
'
./common
'
);
chrome
.
storage
.
local
.
get
([
'
topic_regx
'
,
'
topics
'
,
'
topic_time
'
],
function
(
items
)
{
//读取题库信息
document
.
getElementById
(
'
regx
'
).
value
=
items
.
topic_regx
;
document
.
getElementById
(
'
content
'
).
value
=
items
.
topics
;
});
document
.
getElementById
(
'
submit
'
).
onclick
=
function
()
{
chrome
.
storage
.
local
.
set
({
'
topic_regx
'
:
document
.
getElementById
(
'
regx
'
).
value
,
'
topics
'
:
document
.
getElementById
(
'
content
'
).
value
,
'
topic_time
'
:
Date
.
parse
(
new
Date
())
},
function
()
{
alert
(
'
保存成功
'
);
});
}
document
.
getElementById
(
'
test
'
).
onclick
=
function
()
{
var
reg
=
new
RegExp
(
common
.
dealRegx
(
document
.
getElementById
(
'
regx
'
).
value
,
document
.
getElementById
(
'
topic
'
).
value
));
console
.
log
(
reg
);
var
str
=
document
.
getElementById
(
'
content
'
).
value
;
var
arr
=
reg
.
exec
(
str
);
if
(
arr
.
length
>
0
)
{
document
.
getElementById
(
'
result
'
).
innerHTML
=
'
匹配内容:<br />
'
+
arr
[
0
];
document
.
getElementById
(
'
result
'
).
innerHTML
+=
'
<br /><br /><span style="color:red;">匹配答案:
'
+
(
arr
.
length
>=
2
?
arr
[
1
]
:
''
)
+
'
</span>
'
;
}
}
\ No newline at end of file
src/cxmooc-tools/popup.html
浏览文件 @
57963777
...
...
@@ -61,6 +61,8 @@
<label
for=
"interval"
title=
"播放(题目)完成后n分钟再继续下一个任务"
>
间隔时间:
</label>
<input
type=
"text"
id=
"interval"
style=
"font-size: 10px;width: 30%"
placeholder=
"分钟"
/>
</div>
<br>
<a
href=
"import.html"
target=
"_black"
>
题库导入
</a>
</div>
<div>
<h4>
其他说明:
</h4>
...
...
src/cxmooc-tools/start.js
浏览文件 @
57963777
...
...
@@ -10,13 +10,29 @@ window.onload = function () {
return
;
}
}
injected
(
document
,
'
mooc.js
'
);
document
.
head
.
setAttribute
(
'
chrome-url
'
,
chrome
.
extension
.
getURL
(
''
));
chrome
.
storage
.
sync
.
get
([
'
rand_answer
'
,
'
interval
'
,
'
auto
'
],
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
);
localStorage
[
'
config
'
]
=
JSON
.
stringify
(
items
);
});
chrome
.
storage
.
local
.
get
([
'
topic_regx
'
,
'
topics
'
,
'
topic_time
'
],
function
(
items
)
{
//读取题库信息
if
(
localStorage
[
'
topic_time
'
]
==
undefined
||
localStorage
[
'
topic_time
'
]
<
items
.
topic_time
)
{
localStorage
[
'
topic_regx
'
]
=
items
.
topic_regx
;
localStorage
[
'
topics
'
]
=
items
.
topics
;
localStorage
[
'
topic_time
'
]
=
items
.
topic_time
;
}
});
injected
(
document
,
'
mooc.js
'
);
})
}
...
...
webpack.config.js
浏览文件 @
57963777
...
...
@@ -6,7 +6,8 @@ module.exports = {
start
:
__dirname
+
'
/src/cxmooc-tools/start.js
'
,
action
:
__dirname
+
'
/src/cxmooc-tools/action.js
'
,
background
:
__dirname
+
'
/src/cxmooc-tools/background.js
'
,
popup
:
__dirname
+
'
/src/cxmooc-tools/popup.js
'
popup
:
__dirname
+
'
/src/cxmooc-tools/popup.js
'
,
import
:
__dirname
+
'
/src/cxmooc-tools/import.js
'
},
output
:
{
path
:
__dirname
+
'
/build/cxmooc-tools/src
'
,
...
...
@@ -26,12 +27,12 @@ module.exports = {
new
htmlWebpackPlugin
({
filename
:
__dirname
+
'
/build/cxmooc-tools/src/import.html
'
,
template
:
__dirname
+
'
/src/cxmooc-tools/import.html
'
,
inject
:
'
head
'
,
inject
:
'
body
'
,
title
:
'
导入页面
'
,
minify
:
{
removeComments
:
true
},
chunks
:
[
'
popup
'
]
chunks
:
[
'
import
'
]
})
]
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录