Greasy Fork

Greasy Fork is available in English.

雀魂郊狼监听器

https://github.com/Hyperzlib/Coyote-Majsoul

当前为 2024-07-28 提交的版本,查看 最新版本

// ==UserScript==
// @name        雀魂郊狼监听器
// @namespace   hyperzlib
// @license    AGPL-3.0
// @match       https://game.maj-soul.com/*
// @match       https://mahjongsoul.game.yo-star.com/*
// @match       https://game.mahjongsoul.com/*
// @grant       none
// @version     1.0.3
// @author      https://github.com/Hyperzlib
// @description https://github.com/Hyperzlib/Coyote-Majsoul
// ==/UserScript==

(function(n){typeof define=="function"&&define.amd?define(n):n()})(function(){"use strict";const n={};function o(e){this.bubbles=e.bubbles||!1,this.cancelBubble=e.cancelBubble||!1,this.cancelable=e.cancelable||!1,this.currentTarget=e.currentTarget||null,this.data=e.data||null,this.defaultPrevented=e.defaultPrevented||!1,this.eventPhase=e.eventPhase||0,this.lastEventId=e.lastEventId||"",this.origin=e.origin||"",this.path=e.path||new Array(0),this.ports=e.parts||new Array(0),this.returnValue=e.returnValue||!0,this.source=e.source||null,this.srcElement=e.srcElement||null,this.target=e.target||null,this.timeStamp=e.timeStamp||null,this.type=e.type||"message",this.__proto__=e.__proto__||MessageEvent.__proto__}const d=n.before=function(e,a,t){return e},f=n.after=function(e,a,t){return e},g=n.modifyUrl=function(e){return e};n.resetHooks=function(){n.before=d,n.after=f,n.modifyUrl=g};const c=WebSocket;WebSocket=function(e,a){let t;e=n.modifyUrl(e)||e,this.url=e,this.protocols=a,this.protocols?t=new c(e,a):t=new c(e);const u=t.send;return t.send=function(s){arguments[0]=n.before(s,t.url,t)||s,u.apply(this,arguments)},t._addEventListener=t.addEventListener,t.addEventListener=function(){const s=this;return arguments[0]==="message"&&(arguments[1]=function(i){return function(){arguments[0]=n.after(new o(arguments[0]),t.url,t),arguments[0]!==null&&i.apply(s,arguments)}}(arguments[1])),t._addEventListener.apply(this,arguments)},Object.defineProperty(t,"onmessage",{set:function(){const s=this,i=arguments[0],r=function(){arguments[0]=n.after(new o(arguments[0]),t.url,t),arguments[0]!==null&&i.apply(s,arguments)};t._addEventListener.apply(this,["message",r,!1])}}),t};const l="http://localhost:56556/";window.document.hasFocus(),window.onfocus=()=>{},window.onblur=()=>{},(window.location.host==="game.maj-soul.com"||window.location.host==="game.mahjongsoul.com")&&(n.before=(e,a)=>{var t,u,s,i;if(!a.includes("/game-gateway")&&!a.includes("mjjpgs."))return e;try{const r=new XMLHttpRequest;r.open("POST",`${l}api/event?msg=req&meID=${(i=(s=(u=(t=window==null?void 0:window.GameMgr)==null?void 0:t.Inst)==null?void 0:u.account_data)==null?void 0:s.account_id)!=null?i:""}&game=majsoul`),r.send(e)}catch(r){console.error(r)}return e},n.after=(e,a)=>{var t,u,s,i;if(!a.includes("/game-gateway")&&!a.includes("mjjpgs."))return e;try{const r=e.data,m=new XMLHttpRequest;m.open("POST",`${l}api/event?msg=res&meID=${(i=(s=(u=(t=window==null?void 0:window.GameMgr)==null?void 0:t.Inst)==null?void 0:u.account_data)==null?void 0:s.account_id)!=null?i:""}&game=majsoul`),m.send(r)}catch(r){console.error(r)}return e})});