Giter Club home page Giter Club logo

genshin-tool's Introduction

genshin-tool

此项目的前端界面已不再维护,移步https://github.com/YieldRay/genshin-info-query

请务必保护好自己的 cookie,不要在不受信任的地址输入自己的 cookie。泄露 cookie 可能使你的账号遭到风险!

预览:https://genshin-tool.vercel.app/

获取米游社 cookie

登录米游社后,在地址栏输入 javascript:alert(document.cookie) 弹出窗口内显示 cookie

step1

step2

部署到 Vercel

Deploy with Vercel
可选环境变量 mys_cookie,其值应为米游社 cookie
可选环境变量 acao,设置服务器发送的 Access-Control-Allow-Origin 的值,填入*即可
实例:https://genshin-tool.vercel.app/api?action=gameInfo&target_uid=100000100

本地部署

$ npm install
$ node server
# 设置默认cookie
$ node server "米游社cookie"

module

const api = require("./index")(cookie, self_uid, target_uid, region);
const selfInfo = await api.selfInfo();
const signReward = await api.signReward();
console.log(signReward);

server

统一返回格式

{
    time: 当前时间戳|Number,
    data: 成功返回的数据|Object,
    success: 是否成功|Boolean,
    msg: 错误详情|String,
};


支持 GET 和 POST 请求
为了保护cookie,建议只使用 POST
example:
GET  http://localhost/api?self_uid=...&target_uid=...&cookie=...&action=...
POST  http://localhost/   -j-s-o-n->   body = { self_uid: '', target_uid: '', cookie='', action='' }


action:{
    selfSign, // 执行签到  需要self_uid
    signInfo, // 签到信息  需要self_uid
    signReward, // 签到奖励  不需要 cookie 和 self_uid
    selfInfo, // 账号信息, 据此查询self_uid,然后再签到和查询签到信息 需要self_uid,不需要target_uid
    gameInfo, // 游戏信息,精确到拥有的角色、探索度等  不需要self_uid,需要target_uid
    spiralAbyss1, // 本期深渊  不需要self_uid,需要target_uid
    spiralAbyss2, // 上期深渊  不需要self_uid,需要target_uid
    charDetail, // 角色详情,精确到角色装备的武器、圣遗物、命座  不需要self_uid,需要target_uid
}

简而言之,查询他人信息时只需要 自己的 cookie 和 target_uid,并且只有玩家注册米游社后方可查询其信息

参数 说明
self_uid 自己的 uid,即 cookie 对应账号的 uid
target_uid 欲查询的 uid
cookie 米游社 cookie
region 游戏服务器,默认为 cn_gf01(国服),可选 cn_qd01(渠道)
action 请求的方法名,上文已述

签到

module

const result = await require("./src/sign")(cookie);
console.log(result);

API 形式

部署到 vercel 时 ,访问 https://genshin-tool.vercel.app/api/chechin?cookie=...
本地部署时,访问 http://localhost/api/chechin?cookie=...
若填写了环境变量mys_cookie,直接访问 https://genshin-tool.vercel.app/api/chechin
实例:https://genshin-tool.vercel.app/api/checkin

CLI 形式

$ npm install
$ node checkin "填写cookie"
# 多账号
$ node checkin '["cookie1", "cookie2"]'

Github Action

代码抄的https://github.com/yinghualuowu/GenshinDailyHelper
workflow 添加后缀.yml,secrets 中的 mys_cookie 填写米游社 cookie,多账号时按照格式["cookie1","cookie2"]填写

其他

Vercel 环境变量 vercel

const url = "https://genshin-tool.vercel.app/api";
const data = {
    cookie: "_MHYUUID=....",
    //self_uid: "123456789",
    target_uid: "100010001",
    action: "getCharInfo",
    //region: "cn_gf01",
};

fetch(url, {
    method: "POST",
    body: JSON.stringify(data),
})
    .then(res => res.json())
    .catch(error => console.error("Error:", error))
    .then(response => console.log("Success:", response));

genshin-tool's People

Contributors

yieldray avatar

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.