-
Notifications
You must be signed in to change notification settings - Fork 935
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update 学习强国.js #174
Open
Kleverx
wants to merge
2
commits into
dundunnp:version-14.2
Choose a base branch
from
Kleverx:patch-3
base: version-14.2
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Update 学习强国.js #174
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -392,6 +392,22 @@ media.resumeMusic(); | |
back_track_flag = 2; | ||
// 注意:四人赛和双人对战因无法获取题目,需要ocr | ||
|
||
/** | ||
* 等待需要点击的选项出现,如果出现 第?题、继续挑战,就break | ||
* @param {int} option 第?个选项 | ||
*/ | ||
function waitForRadioButton(optionIndex) { | ||
var endNow = 0 | ||
while(!className('android.widget.RadioButton').depth(32).exists()) { | ||
if(textMatches(/第\d题/).exists() || text('继续挑战').exists()) { | ||
endNow = 1; | ||
break; | ||
} | ||
}; | ||
if (endNow == 0) className('android.widget.RadioButton').depth(32).findOnce(optionIndex).click(); | ||
slp(1.8); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. slp(1.8)是啥意思呢,sleep()? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 我直接复制过来的,就是延时函数 |
||
} | ||
|
||
/** | ||
* 答题 | ||
* @param {int} depth_option 选项控件的深度 | ||
|
@@ -400,8 +416,7 @@ back_track_flag = 2; | |
function do_contest_answer(depth_option, question) { | ||
if (question == "选择正确的读音" || question == "选择词语的正确词形" || question == "下列词形正确的是") { | ||
// 选择第一个 | ||
className('android.widget.RadioButton').depth(depth_option).waitFor(); | ||
className('android.widget.RadioButton').depth(depth_option).findOne().click(); | ||
waitForRadioButton(0) | ||
} else { | ||
var result; | ||
// 发送http请求获取答案 网站搜题速度 r1 > r2 | ||
|
@@ -419,18 +434,12 @@ function do_contest_answer(depth_option, question) { | |
} | ||
} | ||
|
||
className('android.widget.RadioButton').depth(depth_option).waitFor(); | ||
|
||
if (result) { | ||
try { | ||
className('android.widget.RadioButton').depth(depth_option).findOnce(result[0].charCodeAt(3) - 65).click(); | ||
} catch (error) { | ||
// 如果选项不存在,则点击第一个 | ||
className('android.widget.RadioButton').depth(depth_option).findOne().click(); | ||
} | ||
answer = result[0].charCodeAt(3) - 65 | ||
waitForRadioButton(answer) | ||
} else { | ||
// 如果没找到结果则选择第一个 | ||
className('android.widget.RadioButton').depth(depth_option).findOne().click(); | ||
waitForRadioButton(0) | ||
} | ||
} | ||
} | ||
|
@@ -1107,8 +1116,7 @@ function do_contest() { | |
log(question); | ||
if (question) do_contest_answer(32, question); | ||
else { | ||
className('android.widget.RadioButton').depth(32).waitFor(); | ||
className('android.widget.RadioButton').depth(32).findOne().click(); | ||
waitForRadioButton(0) | ||
} | ||
// 等待新题目加载 | ||
while (!textMatches(/第\d题/).exists() && !text('继续挑战').exists() && !text('开始').exists()); | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里貌似并没有解决控件因为某种原因没检测出来卡死的原因
如果检测不出来waitFor()会卡死,但你的while循环也退不出来啊
另外这里的depth()不能写死为32,因为挑战答题的是28
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
挑战答题写成28就好了啊。
我写了以后就从来没有卡死过。
因为检测不到radioButton的情况就是答题结束或者控件未出现