Coder Social home page Coder Social logo

dormitory-uestc's Introduction

Hi there 👋

I am Runtus 😊

I am a 🛠Front-end/Javascript Developer🛠

Top Langs

My Coding Life

Code Time

Profile Views

🐱 My GitHub Data

📦 154.1 kB Used in GitHub's Storage

🚫 Not Opted to Hire

📜 39 Public Repositories

🔑 22 Private Repositories

📊 This Week I Spent My Time On

🕑︎ Time Zone: Asia/Shanghai

💬 Programming Languages: 
HTML                     3 hrs 6 mins        ████████████████████████░   97.00 % 
TypeScript               3 mins              █░░░░░░░░░░░░░░░░░░░░░░░░   02.04 % 
C                        1 min               ░░░░░░░░░░░░░░░░░░░░░░░░░   00.92 % 
C++                      0 secs              ░░░░░░░░░░░░░░░░░░░░░░░░░   00.02 % 
JavaScript               0 secs              ░░░░░░░░░░░░░░░░░░░░░░░░░   00.02 % 

🔥 Editors: 
VS Code                  3 hrs 11 mins       █████████████████████████   100.00 % 

💻 Operating System: 
Mac                      3 hrs 11 mins       █████████████████████████   100.00 % 

Last Updated on 17/05/2024 18:38:57 UTC

🎁My Projects🎁

Readme Card Readme Card

dormitory-uestc's People

Contributors

runtus avatar

Stargazers

 avatar  avatar

Watchers

 avatar

dormitory-uestc's Issues

加上定时开抢的功能会比较好

脚本的源码设计是到选房时间(11:00)需要手动启动,但是现在用脚本的人很多,靠人的手速很难在 11:00 过1秒抢到。

https://github.com/Runtus/dormitory-uestc/blob/9765a3207cd3d927ff912ac3a11d941f267acd80/src/index.ts#L121C1-L121C1

类似 index.ts 中修改成这样,亲测给四个人抢到了,基本挂在后台等结果。

const main = async () => {
  let isBooked = false; // 添加一个标志,表示是否已经抢房成功
  let loopCount = 0; // 添加一个计数器,表示循环的次数
  while(!isBooked){
    loopCount++; // 每次循环,计数器加一
    console.log(`这是第${loopCount}次尝试抢房`); // 在终端打印出循环的次数
    const res = await register()
    if (res.hasRegister) {
      for (let house of config.houses) {
        console.log(`正在抢房 ${house.name} 号`)
        const data = await checkRoom(house.id)
        if (data.isNull) { // 空的,进行选房请求
          console.log('房源为空,开始抢房')
          const promises = data.bed.map(item => (
            got(POST_URL_CHOOSEROOM, {
              method: 'post',
              headers: {
                ...headers,
                Cookie: cookies.find(cookie => cookie.name === item.name).cookie
              },
              form: {
                "bed_id": item.bed_id,
                "choose_bed_auth_counsellor_id": (() => {
                  console.log(item)
                  return item.choose_bed_auth_counsellor_id
                })()
              }
            }).json<{flag: boolean, type: number, data: number, message: string}>()
          ))
          const result = await Promise.all(promises)
          console.log(result)
          if (result.every(item => item.type === 0)) {
            console.log(`恭喜!抢房成功,房号为:${house.name}`)
            isBooked = true;
          } else if (result.every(item => item.type === 1)){
            console.log(`你们貌似抢过房了`)
            isBooked = true;
          } else {
            console.log(`疑似撞车,请登录检查`)
          }
          break;
        } else {
          console.log(`${house.name}房间已有人入驻,开始对下一房间进行抢房操作`)
          continue
        }
      }
      if (!isBooked) {
        console.log('你预定的房间已经没有空位了,请重新进行配置');
      }
    } else {
      console.log('loginID没有注册成功,请重复尝试')
    }
    await new Promise(resolve => setTimeout(resolve, 1000)); // 等待1秒
  }
}



const scheduleStart = () => {
  const targetTime = config.start_time.hour * 60 * 60 + config.start_time.minute * 60 + config.start_time.second; // 11:30:20 in seconds
  console.log(`目标时间: ${config.start_time.hour}:${config.start_time.minute}:${config.start_time.second}`);

  const printIntervalId = setInterval(() => {
    const now = new Date();
    console.log(`现在时间: ${now.getHours()}:${now.getMinutes()}:${now.getSeconds()}`);
  }, 10000); // Print every 30 seconds

  const intervalId = setInterval(() => {
      const now = new Date();
      const currentTime = now.getHours() * 60 * 60 + now.getMinutes() * 60 + now.getSeconds();
      if (currentTime >= targetTime) {
          clearInterval(printIntervalId);
          clearInterval(intervalId);
          console.log(`开始抢房时间: ${now.getHours()}:${now.getMinutes()}:${now.getSeconds()}`);
          main();
      }
  }, 1000);
}

scheduleStart();

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.