add time elapsed between clicking emulator
Summary: Ref T2747 Reviewers: kuba-orlik Reviewed By: kuba-orlik Subscribers: kuba-orlik Maniphest Tasks: T2747 Differential Revision: https://hub.sealcode.org/D1392
This commit is contained in:
parent
771813b5e0
commit
6a0f11f7e1
@ -3,34 +3,58 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<title>Rentgen android</title>
|
<title>Rentgen android</title>
|
||||||
|
<style>
|
||||||
|
main{
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-section{
|
||||||
|
height: 600px;
|
||||||
|
width: 300px;
|
||||||
|
overflow-y: auto;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
margin-left: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.screen{
|
||||||
|
display: inline-block
|
||||||
|
}
|
||||||
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div>
|
<main>
|
||||||
<img id="screen" src="" style="display: inline-block" />
|
<img id="screen" src="" class="screen"/>
|
||||||
<p
|
<p
|
||||||
id="clicks-log"
|
id="clicks-log"
|
||||||
style="
|
class="log-section"
|
||||||
height: 600px;
|
|
||||||
width: 300px;
|
|
||||||
overflow-y: auto;
|
|
||||||
display: inline-block;
|
|
||||||
margin-left: 20px;
|
|
||||||
"
|
|
||||||
></p>
|
></p>
|
||||||
<p
|
<p
|
||||||
id="traffic-log"
|
id="traffic-log"
|
||||||
style="
|
class="log-section"
|
||||||
height: 600px;
|
|
||||||
width: 500px;
|
|
||||||
overflow-y: auto;
|
|
||||||
display: inline-block;
|
|
||||||
margin-left: 20px;
|
|
||||||
"
|
|
||||||
></p>
|
></p>
|
||||||
</div>
|
</main>
|
||||||
<script>
|
<script>
|
||||||
var screen = document.getElementById("screen");
|
var screen = document.getElementById("screen");
|
||||||
var clicksLog = document.getElementById("clicks-log");
|
var clicksLog = document.getElementById("clicks-log");
|
||||||
|
let lastTouch = new Date().getTime();
|
||||||
|
|
||||||
|
const calculateElapsedTime = (last) => {
|
||||||
|
const currentTouch = new Date().getTime();
|
||||||
|
const elapsedTime = currentTouch - lastTouch;
|
||||||
|
const elapsedSec = Math.round(elapsedTime / 1000);
|
||||||
|
lastTouch = currentTouch;
|
||||||
|
return elapsedSec;
|
||||||
|
};
|
||||||
|
|
||||||
|
const waitToLog = (clickInfoText) => {
|
||||||
|
const clickInfo = document.createElement("span");
|
||||||
|
const waitInfo = document.createElement("span");
|
||||||
|
waitInfo.textContent = `await wait(${calculateElapsedTime(lastTouch)});`
|
||||||
|
clicksLog.appendChild(waitInfo);
|
||||||
|
clickInfo.textContent = clickInfoText;
|
||||||
|
clicksLog.appendChild(clickInfo);
|
||||||
|
}
|
||||||
|
|
||||||
async function displayImage() {
|
async function displayImage() {
|
||||||
try {
|
try {
|
||||||
@ -51,7 +75,8 @@
|
|||||||
phoneY <= 640 &&
|
phoneY <= 640 &&
|
||||||
phoneY >= 0
|
phoneY >= 0
|
||||||
) {
|
) {
|
||||||
clicksLog.innerText += `await click(${phoneX}, ${phoneY});\n`;
|
waitToLog(`await click(${phoneX}, ${phoneY});`);
|
||||||
|
|
||||||
await fetch("touch", {
|
await fetch("touch", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
@ -59,6 +84,7 @@
|
|||||||
},
|
},
|
||||||
body: `x=${phoneX}&y=${phoneY}`,
|
body: `x=${phoneX}&y=${phoneY}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user