Last active
October 27, 2022 04:27
-
-
Save yige233/aecfd74dd3d9211270ffec027d562059 to your computer and use it in GitHub Desktop.
不用客户端,就能随意设置dodo上显示的正在玩的游戏
This file contains hidden or 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
| // ==UserScript== | |
| // @name 正在玩啥? | |
| // @namespace http://tampermonkey.net/ | |
| // @version 0.1 | |
| // @description try to take over the world! | |
| // @author yige233 | |
| // @match https://www.imdodo.com/* | |
| // @icon https://www.imdodo.com/favicon.ico | |
| // @grant GM.registerMenuCommand | |
| // @require https://cdn.bootcdn.net/ajax/libs/crypto-js/4.1.1/crypto-js.min.js | |
| // ==/UserScript== | |
| (function() { | |
| 'use strict'; | |
| // Your code here... | |
| function getSig(val, key) { | |
| const e = CryptoJS.HmacSHA1(val, key); | |
| var t = e.words, | |
| n = e.sigBytes, | |
| i = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; | |
| e.clamp(); | |
| for (var r = [], o = 0; o < n; o += 3) | |
| for (var s = t[o >>> 2] >>> 24 - o % 4 * 8 & 255, a = t[o + 1 >>> 2] >>> 24 - (o + 1) % 4 * 8 & 255, c = t[o + 2 >>> 2] >>> 24 - (o + 2) % 4 * 8 & 255, l = s << 16 | a << 8 | c, u = 0; u < 4 && o + .75 * u < n; u++) r.push(i.charAt(l >>> 6 * (3 - u) & 63)); | |
| var d = i.charAt(64); | |
| if (d) | |
| while (r.length % 4) r.push(d); | |
| return r.join(""); | |
| }; | |
| function encodeSearch(obj, urlSafe = false) { | |
| const arr = []; | |
| for (const key in obj) arr.push(`${key}=${urlSafe?encodeURIComponent(obj[key]):obj[key]}`); | |
| return arr.join("&"); | |
| }; | |
| function request(url, data) { | |
| return fetch(url, { | |
| "headers": { | |
| "clienttype": "3", | |
| "clientversion": "0.9.16", | |
| "content-type": "application/x-www-form-urlencoded;charset=UTF-8", | |
| "token": localStorage.token | |
| }, | |
| "body": encodeSearch(data, true), | |
| "method": "POST", | |
| }); | |
| } | |
| GM.registerMenuCommand("设置正在玩", async () => { | |
| const body = { | |
| gameName: "和431击剑🤺", | |
| beginTime: Date.now(), | |
| uid: localStorage.uid, | |
| token: localStorage.token, | |
| clientType: 3, | |
| apikey: "CK18tnKeKDN", | |
| timestamp: Date.now(), | |
| }; | |
| const game = prompt("你在玩啥呢?", body.gameName); | |
| if (game) { | |
| body.gameName = game; | |
| body.sig = getSig(encodeSearch(body), "t8yqYCqv68rKOwgPRUBv4Z2hS4kKajHc0yYzrXLf") //计算hmacsha1 | |
| request("https://apis.imdodo.com/pc/games/setting/show", body); | |
| }; | |
| }); | |
| GM.registerMenuCommand("停止显示正在玩", async () => { | |
| const body = { | |
| uid: localStorage.uid, | |
| token: localStorage.token, | |
| clientType: 3, | |
| apikey: "9mEnDRJrkl6", | |
| timestamp: Date.now(), | |
| }; | |
| body.sig = getSig(encodeSearch(body), "0ZFDcgZX9iigWbbzmHmqcMFFpZFZcrOu91TsRVCU") //计算hmacsha1 | |
| request("https://apis.imdodo.com/pc/games/setting/show", body); | |
| }); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment