Compare commits
No commits in common. "41d22824a909be65059ad9083743edbed659c6ef" and "458fb72b24ee9410c89c2ed32015b1168b19e098" have entirely different histories.
41d22824a9
...
458fb72b24
1
rust-namer/.gitignore
vendored
1
rust-namer/.gitignore
vendored
@ -1 +0,0 @@
|
|||||||
target
|
|
1457
rust-namer/Cargo.lock
generated
1457
rust-namer/Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -1,12 +0,0 @@
|
|||||||
[package]
|
|
||||||
name = "rust-namer"
|
|
||||||
version = "0.1.0"
|
|
||||||
edition = "2021"
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
anyhow = { version = "1.0", features = ["backtrace"] }
|
|
||||||
serde = { version = "1.0", features = ["serde_derive"] }
|
|
||||||
serde_json = "1.0"
|
|
||||||
tokio = { version = "1.36.0", features = ["full"] }
|
|
||||||
|
|
||||||
thirtyfour = "0.31.0"
|
|
@ -1,21 +0,0 @@
|
|||||||
let has_done_target = document.getElementById('done_target');
|
|
||||||
if (has_done_target) {
|
|
||||||
has_done_target.display = 'none';
|
|
||||||
has_done_target.done = 'false';
|
|
||||||
} else {
|
|
||||||
let target = document.createElement("div", style = "display: none;");
|
|
||||||
target.id = "done_target";
|
|
||||||
target.style.display = "none";
|
|
||||||
document.body.appendChild(target);
|
|
||||||
}
|
|
||||||
// 监听消息
|
|
||||||
window.addEventListener('message', function (event) {
|
|
||||||
console.log('Received message:', event.data, event);
|
|
||||||
if (event.data.hasOwnProperty("all")) {
|
|
||||||
// 为 done_target 添加 done=true 属性
|
|
||||||
let done_target = document.getElementById('done_target');
|
|
||||||
done_target.setAttribute('done', 'true');
|
|
||||||
done_target.win_data = event.data;
|
|
||||||
console.log('done_target:', done_target);
|
|
||||||
}
|
|
||||||
});
|
|
@ -1,16 +0,0 @@
|
|||||||
use anyhow::Result;
|
|
||||||
|
|
||||||
mod runner;
|
|
||||||
|
|
||||||
#[tokio::main]
|
|
||||||
async fn main() -> Result<()> {
|
|
||||||
let web_runner = runner::WebDriverRunner::init("https://shenjack.top:82/md5").await?;
|
|
||||||
|
|
||||||
let result = web_runner.raw_flight("aaaaaaa\nnnnnn".to_string()).await?;
|
|
||||||
|
|
||||||
println!("{}", result.str_without_pic());
|
|
||||||
|
|
||||||
web_runner.quit().await?;
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
@ -1,97 +0,0 @@
|
|||||||
use std::time::Duration;
|
|
||||||
|
|
||||||
use anyhow::Result;
|
|
||||||
use serde::{Deserialize, Serialize};
|
|
||||||
use thirtyfour::prelude::*;
|
|
||||||
|
|
||||||
const INSERT_JS: &str = include_str!("../insert.js");
|
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
|
||||||
pub struct WinData {
|
|
||||||
pub all: Vec<Vec<Vec<String>>>,
|
|
||||||
pub winners: Vec<String>,
|
|
||||||
pub pic: String, // base64 img
|
|
||||||
#[serde(rename = "firstKill")]
|
|
||||||
pub first_kill: Option<String>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl WinData {
|
|
||||||
pub fn str_without_pic(&self) -> String {
|
|
||||||
format!(
|
|
||||||
"Winners: {:?}\nFirst Kill: {:?}\nAll: {:?}",
|
|
||||||
self.winners, self.first_kill, self.all
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub struct TeamRunner {
|
|
||||||
pub time_out: Duration,
|
|
||||||
/// 每个队伍的成员, 队伍名
|
|
||||||
pub teams: Vec<(String, Vec<String>)>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl TeamRunner {
|
|
||||||
// pub fn builder
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct WebDriverRunner {
|
|
||||||
pub driver: WebDriver,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl std::fmt::Display for WebDriverRunner {
|
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
||||||
write!(f, "Runner")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl WebDriverRunner {
|
|
||||||
pub async fn init(target_url: impl AsRef<str>) -> Result<Self> {
|
|
||||||
let caps = DesiredCapabilities::edge();
|
|
||||||
let driver = WebDriver::new("http://localhost:9515", caps).await?;
|
|
||||||
driver.goto(target_url.as_ref()).await?;
|
|
||||||
driver.execute(INSERT_JS, vec![]).await?;
|
|
||||||
// insert.js
|
|
||||||
// 预备环境
|
|
||||||
|
|
||||||
Ok(Self { driver })
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn raw_flight(&self, teams: String) -> Result<WinData> {
|
|
||||||
let done_target = self.driver.find(By::Id("done_target")).await?;
|
|
||||||
let go_btn = self.driver.find(By::ClassName("goBtn")).await?;
|
|
||||||
let fast_forward_btn = self.driver.find(By::Id("fastBtn")).await?;
|
|
||||||
let name_input = self.driver.find(By::Id("input_name")).await?;
|
|
||||||
|
|
||||||
name_input.send_keys(teams).await?;
|
|
||||||
|
|
||||||
go_btn.click().await?;
|
|
||||||
tokio::time::sleep(std::time::Duration::from_millis(100)).await; // 等一会
|
|
||||||
fast_forward_btn.click().await?;
|
|
||||||
|
|
||||||
done_target
|
|
||||||
.wait_until()
|
|
||||||
.has_attribute("done", "true")
|
|
||||||
.await?;
|
|
||||||
|
|
||||||
let win_data = self
|
|
||||||
.driver
|
|
||||||
.execute("return arguments[0].win_data", vec![done_target.to_json()?])
|
|
||||||
.await?;
|
|
||||||
let win_data: WinData = serde_json::from_value(win_data.json().to_owned())?;
|
|
||||||
Ok(win_data)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn flight(&self, teams: Vec<Vec<String>>) -> Result<WinData> {
|
|
||||||
let done_target = self.driver.find(By::Id("done_target")).await?;
|
|
||||||
let go_btn = self.driver.find(By::ClassName("goBtn")).await?;
|
|
||||||
let fast_forward_btn = self.driver.find(By::Id("fastBtn")).await?;
|
|
||||||
let name_input = self.driver.find(By::Id("input_name")).await?;
|
|
||||||
todo!("flight")
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn quit(self) -> Result<()> {
|
|
||||||
self.driver.quit().await?;
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
@ -108,7 +108,7 @@ pub fn cacl(config: CacluateConfig, id: u64, outfile: &PathBuf) {
|
|||||||
start_time = std::time::Instant::now();
|
start_time = std::time::Instant::now();
|
||||||
k = 0;
|
k = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prop + config.prop_allow as f32) > config.prop_expect as f32 {
|
if (prop + config.prop_allow as f32) > config.prop_expect as f32 {
|
||||||
let name = gen_name(i as u64);
|
let name = gen_name(i as u64);
|
||||||
let full_name = format!("{}@{}", name, config.team);
|
let full_name = format!("{}@{}", name, config.team);
|
||||||
|
Loading…
Reference in New Issue
Block a user