Bumpyball.io/Pucks.io Decoder

To understand data of messages you send

此腳本不應該直接安裝,它是一個供其他腳本使用的函式庫。欲使用本函式庫,請在腳本 metadata 寫上: // @require https://update.gf.qytechs.cn/scripts/539331/1671568/BumpyballioPucksio%20Decoder.js

  1. // ==UserScript==
  2. // @name Bumpyball.io/Pucks.io Decoder
  3. // @namespace https://gf.qytechs.cn/en/users/1462379-3lectr0n-nj
  4. // @version 1
  5. // @description To understand data of messages you send
  6. // @author 3lectr0N!nj@
  7. // @icon https://cdn.discordapp.com/avatars/1240124778728132693/02be852a2bd883c3e15fd41177bf7a3f.webp
  8. // @grant none
  9. // ==/UserScript==
  10. let Packet = window.packet = {
  11. 0:{},
  12. 1:{
  13. 8: ["PacketId","int"],
  14. 18: ["Data","dict",{
  15. 10: ["name", "string"],
  16. 18: ["uid", "string"],
  17. 24: ["version", "uint"],
  18. 32: ["skinId", "uint"],
  19. 42: ["password", "string"],
  20. 56: ["authenticationMethod", "uint"],
  21. }]
  22. },
  23. 2:{
  24. 8: ["PacketId","int"],
  25. 18: ["Data","dict",{
  26. 10: ["entities", "dict", {
  27. 10: ["list", "arr", {
  28. 8: ["id", "int"],
  29. 18: ["entity", "dict", {
  30. 10: ["position", "dict", {
  31. 13: ["x", "float"],
  32. 21: ["z", "float"],
  33. }],
  34. 16: ["entityType", "uint"],
  35. 24: ["playerId", "uint"],
  36. 37: ["rotation", "float"],
  37. 42: ["forces", "dict", {
  38. 13: ["x", "float"],
  39. 21: ["z", "float"],
  40. }],
  41. }],
  42. }],
  43. }],
  44. 18: ["players", "dict", {
  45. 10: ["list", "arr", {
  46. 8: ["id", "int"],
  47. 18: ["name", "string"],
  48. 56: ["bot", "bool"],
  49. 24: ["goals", "uint"],
  50. 32: ["assits", "uint"],
  51. 40: ["team", "uint"],
  52. 48: ["skinId", "uint"],
  53. 64: ["experience", "uint"],
  54. }]
  55. }],
  56. 24: ["playerId", "uint"],
  57. 34: ["gameState", "dict", {
  58. 13: ["timeRemaining", "float"],
  59. 18: ["teams", "arr", {
  60. 8: ["teamId", "int"],
  61. 16: ["score", "int"],
  62. }],
  63. 24: ["gameState", "int"],
  64. }],
  65. 42: ["hostName", "string"]
  66. }]
  67. },
  68. 3:{
  69. 8: ["PacketId","int"],
  70. 18: ["Data","dict",{
  71. 10: ["list", "arr", {
  72. 8: ["id", "int"],
  73. 18: ["name", "string"],
  74. 56: ["bot", "int"],
  75. 24: ["goals", "uint"],
  76. 32: ["assits", "uint"],
  77. 40: ["team", "uint"],
  78. 48: ["skinId", "uint"],
  79. 64: ["experience", "uint"],
  80. }]
  81. }]
  82. },
  83. 4:{
  84. 8: ["PacketId", "uint"],
  85. 18: ["Data", "dict",{
  86. 8: ["playerId", "uint"],
  87. }]
  88. },
  89. 5:{
  90. 8: ["PacketId","int"],
  91. 18: ["Data","dict",{
  92. 8: ["playerId", "uint"],
  93. 18: ["message", "string"]
  94. }]
  95. },
  96. 6:{
  97. 8: ["PacketId","int"],
  98. 18: ["Data","dict",{
  99. 8: ["id", "uint"],
  100. 18: ["position", "dict", {
  101. 13: ["x", "float"],
  102. 21: ["z", "float"]
  103. }],
  104. 29: ["rotation", "float"],
  105. }]
  106. },
  107. 7:{
  108. 8: ["PacketId", "int"],
  109. 18: ["Data", "dict",{
  110. 8: ["command", "bool"],
  111. 18: ["position", "dict", {
  112. 13: ["x", "float"],
  113. 21: ["z", "float"],
  114. }],
  115. 24: ["EID", "uint"],
  116. }]
  117. },
  118. 8:{
  119. 8: ["PacketId", "int"],
  120. 18: ["Data", "dict",{
  121. 16: ["id", "uint"],
  122. 26: ["entity", "dict", {
  123. 10: ["position", "dict", {
  124. 13: ["x", "float"],
  125. 21: ["z", "float"],
  126. }],
  127. 16: ["entityType", "uint"],
  128. 24: ["playerId", "uint"],
  129. 37: ["rotation", "float"],
  130. 42: ["forces", "dict", {
  131. 13: ["x", "float"],
  132. 21: ["z", "float"],
  133. }],
  134. }]
  135. }]
  136. },
  137. 9:{
  138. 8: ["PacketId", "uint"],
  139. 18: ["Data", "dict",{
  140. 8: ["id", "uint"],
  141. 24: ["reason", "uint"],
  142. 18: ["entity", "dict", {
  143. 10: ["position", "dict", {
  144. 13: ["x", "float"],
  145. 21: ["z", "float"],
  146. }],
  147. 24: ["playerId", "uint"],
  148. 16: ["entityType", "uint"],
  149. 37: ["rotation", "float"],
  150. 42: ["forces", "dict", {
  151. 13: ["x", "float"],
  152. 21: ["z", "float"],
  153. }],
  154. }],
  155. }]
  156. },
  157. 10:{},
  158. 11:{
  159. 8: ["PacketId","int"],
  160. 18: ["Data","dict",{
  161. 10: ["message", "string"],
  162. 16: ["playerIdA", "uint"],
  163. 24: ["playerIdB", "uint"],
  164. }]
  165. },
  166. 12:{
  167. 8: ["PacketId", "int"],
  168. 18: ["Data", "dict",{
  169. 13: ["timeRemaining", "float"],
  170. 18: ["teams", "arr", {
  171. 8: ["teamId", "int"],
  172. 16: ["score", "int"],
  173. }],
  174. 24: ["gameState", "int"],
  175. }]
  176. },
  177. 13:{
  178. 8: ["PacketId", "int"],
  179. 18: ["Data", "dict",{
  180. 8: ["team", "uint"],
  181. 16: ["id", "uint"]
  182. }]
  183. },
  184. 14:{
  185. 8: ["PacketId","int"],
  186. 18: ["Data","dict",{
  187. 10: ["list", "arr", {
  188. 8: ["id", "int"],
  189. 18: ["name", "string"],
  190. 56: ["bot", "bool"],
  191. 24: ["goals", "uint"],
  192. 32: ["assits", "uint"],
  193. 40: ["team", "uint"],
  194. 48: ["skinId", "uint"],
  195. 64: ["experience", "uint"],
  196. }],
  197. }]
  198. },
  199. 15:{
  200. 8: ["PacketId","int"],
  201. 18: ["Data","dict",{
  202. 16: ["playerId", "uint"],
  203. }]
  204. },
  205. 16:{},
  206. 17:{
  207. 8: ["PacketId","int"],
  208. 18: ["Data","dict",{
  209. 10: ["player","dict",{
  210. 10: ["uid","string"],
  211. 34: ["name","string"],
  212. 40: ["goals","int"],
  213. 48: ["assits","int"],
  214. 56: ["wins","int"],
  215. 64: ["draws","int"],
  216. 72: ["lost","int"],
  217. 80: ["spareExp","int"],
  218. 88: ["exp","int"],
  219. 96: ["skinId","int"]
  220. }],
  221. }]
  222. },
  223. 18:{},
  224. 19:{}
  225. }
  226. class BR {
  227. arr=[];
  228. i=0;
  229. constructor (a) {
  230. a??=[];
  231. this.arr = [...a];
  232. }
  233. skip(){
  234. return (this.arr.length - this.i) ;
  235. }
  236. rbs (size){
  237. let r = this.arr.slice(this.i,this.i+size);
  238. this.i+=size;
  239. return r ;
  240. }
  241. rb (){
  242. return this.rbs(1)[0]
  243. }
  244. int7(){
  245. let r = 0;
  246. let b = 0;
  247.  
  248. while (b !== 35) {
  249. let c = this.rb();
  250. r |= (c & 127) << b;
  251.  
  252. if ((c & 128) === 0) {
  253. return [r, (b / 7) + 1];
  254. }
  255.  
  256. b += 7;}
  257. }
  258. str(){
  259. let l = this.int7()[0]
  260. let s = new TextDecoder().decode(new Uint8Array(this.rbs(l)))
  261. return s
  262. }
  263. f32(){
  264. let l = new Uint8Array(this.rbs(4))
  265. let f = new Float32Array(l.buffer)[0]
  266. return f
  267. }
  268. dec(json){
  269. let l
  270. let s
  271. let arrs=[]
  272. let v
  273. let obj ={};
  274. for (let byte in json) {
  275. let [keyName, valueType] = json[byte];
  276.  
  277. if (["int", "bool", "uint","float"].includes(valueType)) {
  278. obj[byte] = [keyName,valueType,0];
  279. }
  280. }
  281. for (let byte in json) {
  282. byte = Number(byte)
  283. let [keyName, valueType] = json[byte];
  284. }
  285. while(this.skip()>0){
  286. let byte = this.rb()
  287. let [keyName,valueType] = json[byte]
  288. let value
  289. switch(valueType){
  290. case "int":
  291. case "uint":
  292. case "bool":
  293. value = this.int7()[0];
  294. break;
  295. case "string":
  296. value =this.str();
  297. break;
  298. case "float":
  299. value =this.f32();
  300. break;
  301. case "dict":
  302. l = this.int7()[0]
  303. s = new BR(new Uint8Array(this.rbs(l)))
  304. value = s.dec(json[byte][2])
  305. break;
  306. case "arr":
  307. l = this.int7()[0]
  308. s = new BR(new Uint8Array(this.rbs(l)))
  309. v = s.dec(json[byte][2])
  310. arrs.push(v)
  311. value = arrs
  312. }
  313. obj[byte] = [keyName,valueType,value];
  314. }
  315. return obj
  316. }
  317. bit7(num){
  318. for(;num>=128;num>>=7)this.arr.push((128|num)%256);return this.arr.push(num%256)
  319. }
  320. ft32(num){
  321. let f = new Float32Array([num])
  322. let b = new Uint8Array(f.buffer)
  323. this.arr.push(...b)
  324. }
  325. istr(value){
  326. let s = new TextEncoder().encode(value)
  327. this.arr.push(s.length,...s)
  328. }
  329. ab(value){
  330. this.arr.push(value)
  331. }
  332. enc(json){
  333. for (let byte in json) {
  334. let [keyName,valueType,value] = json[byte]
  335. let da
  336. let a
  337. switch(value){
  338. case 0:
  339. valueType = ""
  340. }
  341. switch(valueType){
  342. case "int":
  343. case "uint":
  344. case "bool":
  345. this.ab(Number(byte))
  346. this.bit7(value)
  347. break;
  348. case "string":
  349. this.ab(Number(byte))
  350. this.istr(value);
  351. break;
  352. case "float":
  353. this.ab(Number(byte))
  354. this.ft32(value);
  355. break;
  356. case "dict":
  357. da = new BR([]).enc(json[Number(byte)][2])
  358. this.ab(Number(byte))
  359. this.bit7(da.length)
  360. this.arr.push(...da)
  361. break;
  362. case "arr":
  363. value.forEach(index=>{
  364. a = new BR([]).enc(index)
  365. this.ab(Number(byte))
  366. this.bit7(a.length)
  367. this.arr.push(...a)
  368. })
  369. }
  370. }
  371. return this.arr
  372. }
  373. Sdecoder(d){
  374. let json ={}
  375. let sd = new BR(d)
  376. json = sd.dec(Packet[d[1]])
  377. return json
  378. }
  379. Sencoder(j){
  380. let a =[]
  381. a = new BR([]).enc(j)
  382. return a
  383. }
  384. Mdecoder(d){
  385. let j = {}
  386. let r=(-1)
  387. let s
  388. let wa = new BR(d)
  389. while(wa.skip()>0){
  390. wa.rb()
  391. let l = wa.int7()[0]
  392. let a = wa.rbs(l)
  393. let s = new BR().Sdecoder(a)
  394. j[r+=1] = s
  395. }
  396. return j
  397. }
  398. Mencoder(j){
  399. let a_
  400. let a =[]
  401. for (let b in j) {
  402. let _j = j[b]
  403. a_ = new BR([]).Sencoder(_j)
  404. let le = new BR([])
  405. le.bit7(a_.length)
  406. let l = le.arr
  407. a.push(10,...l,...a_)
  408. }
  409. return a
  410. }
  411. }
  412. window.BR = BR

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址