Last active
April 11, 2024 16:49
-
-
Save manatails/625fccaf2eddd1545a92d46299835fb4 to your computer and use it in GitHub Desktop.
Mahjong Soul Replay UI Toggle
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 hidereplayUI | |
| // @namespace https://manatails.net/ | |
| // @version 0.1 | |
| // @description Mahjong Soul Replay UI Toggle | |
| // @author manatails | |
| // @include https://mahjongsoul.game.yo-star.com/* | |
| // @include https://game.mahjongsoul.com/* | |
| // @include https://majsoul.union-game.com/0/* | |
| // @icon https://game.mahjongsoul.com/favicon.ico | |
| // @run-at document-start | |
| // ==/UserScript== | |
| document.addEventListener("DOMContentLoaded", function() | |
| { | |
| const keycode = 90; | |
| function checkscene(scene) | |
| { | |
| return scene && ((scene.Inst && scene.Inst._enable) || (scene._Inst && scene._Inst._enable)); | |
| } | |
| function toggleReplayUI() | |
| { | |
| if (checkscene(uiscript.UI_Replay)) | |
| { | |
| uiscript.UI_Replay.Inst.me.visible = !uiscript.UI_Replay.Inst.me.visible; | |
| } | |
| } | |
| document.addEventListener("keydown", function(e) | |
| { | |
| e = e || window.event; | |
| if ((keycode == e.keyCode || keycode == e.key)) | |
| { | |
| toggleReplayUI(); | |
| } | |
| }); | |
| setTimeout(function(){ | |
| var layaCanvas = document.getElementById('layaCanvas'); | |
| layaCanvas.addEventListener("click", function(e) | |
| { | |
| e = e || window.event; | |
| let rect = layaCanvas.getBoundingClientRect(); | |
| let x = e.clientX - rect.left; | |
| let y = e.clientY - rect.top; | |
| let xp = x / rect.width; | |
| let yp = y / rect.height; | |
| if (xp <= 0.15 && yp >= 0.85) | |
| { | |
| toggleReplayUI(); | |
| } | |
| }); | |
| }, 1000); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment