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.2
// @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 u(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 b=n.before=function(e,i,t){return e},y=n.after=function(e,i,t){return e},v=n.modifyUrl=function(e){return e};n.resetHooks=function(){n.before=b,n.after=y,n.modifyUrl=v};const l=WebSocket;WebSocket=function(e,i){let t;e=n.modifyUrl(e)||e,this.url=e,this.protocols=i,this.protocols?t=new l(e,i):t=new l(e);const o=t.send;return t.send=function(s){arguments[0]=n.before(s,t.url,t)||s,o.apply(this,arguments)},t._addEventListener=t.addEventListener,t.addEventListener=function(){const s=this;return arguments[0]==="message"&&(arguments[1]=function(a){return function(){arguments[0]=n.after(new u(arguments[0]),t.url,t),arguments[0]!==null&&a.apply(s,arguments)}}(arguments[1])),t._addEventListener.apply(this,arguments)},Object.defineProperty(t,"onmessage",{set:function(){const s=this,a=arguments[0],r=function(){arguments[0]=n.after(new u(arguments[0]),t.url,t),arguments[0]!==null&&a.apply(s,arguments)};t._addEventListener.apply(this,["message",r,!1])}}),t};const d="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,i)=>{var t,o,s,a;if(!i.includes("/game-gateway"))return e;try{const r=new XMLHttpRequest;r.open("POST",`${d}api/event?msg=req&meID=${(a=(s=(o=(t=window==null?void 0:window.GameMgr)==null?void 0:t.Inst)==null?void 0:o.account_data)==null?void 0:s.account_id)!=null?a:""}&game=majsoul`),r.send(e)}catch(r){console.error(r)}return e},n.after=(e,i)=>{var t,o,s,a,r,f,m,w,h,g;if(!i.includes("/game-gateway"))return e;try{const c=e.data,_=window.screenX+((o=(t=document.querySelector("#layaCanvas"))==null?void 0:t.offsetLeft)!=null?o:0)/window.devicePixelRatio,P=window.screenY+window.outerHeight-window.innerHeight+((a=(s=document.querySelector("#layaCanvas"))==null?void 0:s.getBoundingClientRect().y)!=null?a:0),E=((r=window.layaCanvas.width)!=null?r:0)/window.devicePixelRatio,L=((f=window.layaCanvas.height)!=null?f:0)/window.devicePixelRatio,S=window.devicePixelRatio,p=new XMLHttpRequest;p.open("POST",`${d}api/event?msg=res&meID=${(g=(h=(w=(m=window==null?void 0:window.GameMgr)==null?void 0:m.Inst)==null?void 0:w.account_data)==null?void 0:h.account_id)!=null?g:""}&game=majsoul`),p.send(c)}catch(c){console.error(c)}return e})});