Extra Sound Settings

Adds a better version of mute, that mutes everything but claps, pings and clicks. It also adds the ability to hear when people are typing within a certain range around you.

当前为 2021-06-27 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Extra Sound Settings
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.1
  5. // @description Adds a better version of mute, that mutes everything but claps, pings and clicks. It also adds the ability to hear when people are typing within a certain range around you.
  6. // @author Zoltar
  7. // @match http://manyland.com/*
  8. // @icon https://cdn.discordapp.com/icons/852442189283983380/a_70793eeb1f509f9c4aa1021e5691fab4.webp
  9. // @grant GM.setValue
  10. // @grant GM.getValue
  11. // ==/UserScript==
  12.  
  13. (function () {
  14. 'use strict';
  15.  
  16. // took this part from Eternity's mod
  17. async function loadObf() {
  18. if (typeof Deobfuscator == 'undefined')
  19. await $.getScript("https://cdn.jsdelivr.net/gh/parseml/many-deobf@latest/deobf.js")
  20.  
  21. }
  22. // Parses smooth loader
  23. !async function loader() {
  24. let loading = setInterval(() => {
  25. if (typeof ig === "undefined") return
  26. else if (typeof ig.game === "undefined") return
  27. else if (typeof ig.game.screen === "undefined") return
  28. else if (ig.game.screen.x == 0) return
  29. else if (typeof Settings !== "function") return
  30.  
  31. clearInterval(loading);
  32. loadObf().then(async () => {
  33.  
  34. let pasteCheck = Deobfuscator.function(ig.game.player, 'Boolean(b&&b', true);
  35. let slotPass = Deobfuscator.object(ig.game, 'slots', true);
  36. let storedPasteCheck = ig.game.player[pasteCheck];
  37.  
  38.  
  39. ig.game.settings.add = Deobfuscator.function(ig.game.settings, 'Math.min(ig.system.scale,5)', true);
  40. ig.game.settings.header = Deobfuscator.function(ig.game.settings, 'text-transform: uppercase;', true);
  41. ig.game.settings.typeInterval = 1;
  42.  
  43.  
  44. // getPlayerChat depends on this
  45. Deobfuscator.findByType = (object, type, returnKey) => {
  46.  
  47. let keyFound = null;
  48.  
  49. Object.keys(object).forEach((i) => {
  50. if (object[i] === null)
  51. return;
  52.  
  53. if (object[i].constructor === type)
  54. keyFound = returnKey ? i : object[i];
  55. });
  56.  
  57. return keyFound;
  58.  
  59. }
  60.  
  61.  
  62. const getPlayerChat = target => {
  63. updatePlayers();
  64. let chat = "";
  65. ig.game.players.forEach(player => {
  66. let playerId = Deobfuscator.variableByLength(ig.game.players[1], 24, true)
  67. if (player[playerId] === target) {
  68.  
  69. let playerChat = Deobfuscator.object(player, 'player', false);
  70. playerChat.object = Deobfuscator.findByType(playerChat, Array, false);
  71.  
  72. if (playerChat.object.length != 0) {
  73. let index = playerChat.object.length - 1;
  74. chat = Deobfuscator.findByType(playerChat.object[index], String, false);
  75. }
  76. }
  77. });
  78.  
  79. return chat;
  80. }
  81.  
  82. function getDistance(x1, y1, x2, y2) {
  83. let xDistance = x2 - x1;
  84. let yDistance = y2 - y1;
  85.  
  86. return Math.sqrt(Math.pow(xDistance, 2) + Math.pow(yDistance, 2));
  87. }
  88.  
  89.  
  90. ig.game.settings.betterMute = function () {
  91. if (!this.btm) {
  92.  
  93. let whiteListedSounds = ["ping", "clap"];
  94. if (ig.game.settings.tps) whiteListedSounds.push("click");
  95.  
  96.  
  97. ig.game.player[pasteCheck] = function (a) {
  98. if (a === "mutesPastes") return true;
  99. var b = this.attachments[ig.game[slotPass].slots.WEARABLE];
  100.  
  101. return Boolean(b && b.attributes && b.attributes[a])
  102. }
  103.  
  104. for (let sound of Object.keys(ig.game.sounds)) {
  105. if (!whiteListedSounds.includes(sound)) {
  106. ig.game.sounds[sound].volume = 0;
  107.  
  108. }
  109. }
  110. this.btm = !this.btm
  111. GM.setValue("bettermute", this.btm);
  112.  
  113. } else {
  114. ig.game.player[pasteCheck] = storedPasteCheck;
  115. for (let sound of Object.keys(ig.game.sounds)) {
  116. ig.game.sounds[sound].volume = 1;
  117.  
  118. }
  119. this.btm = !this.btm;
  120. GM.setValue("bettermute", this.btm);
  121. }
  122.  
  123. }
  124.  
  125. ig.game.settings.typeSound = function () {
  126.  
  127. let chatBuffer = [{ id: "", message: "" }]
  128. let chatterIds = [""];
  129.  
  130. if (!this.tps) {
  131. ig.game.settings.typeInterval = setInterval(() => {
  132. updatePlayers();
  133. for (let player of ig.game.players) {
  134. if (ig.game.players.length == 0) return;
  135.  
  136. let playerId = Deobfuscator.variableByLength(ig.game.players[1], 24, true)
  137.  
  138. if (getDistance(ig.game.player.pos.x, ig.game.player.pos.y, player.pos.x, player.pos.y) <= 230 && player[playerId] != ig.game.player.id) {
  139. if (!chatterIds.includes(player[playerId])) {
  140. chatBuffer.push({ id: player[playerId], message: getPlayerChat(player[playerId]) })
  141. chatterIds.push(player[playerId])
  142. }
  143.  
  144. for (let chatter of chatBuffer) {
  145. if (chatter.id === player[playerId]) {
  146.  
  147. if (chatter.message != getPlayerChat(player[playerId])) {
  148. ig.game.sounds.click.play();
  149. }
  150. chatter.message = getPlayerChat(player[playerId]);
  151.  
  152. }
  153. }
  154.  
  155. }
  156. }
  157. }, 50)
  158. this.tps = !this.tps;
  159. GM.setValue("typesound", this.tps);
  160.  
  161. } else {
  162. clearInterval(ig.game.settings.typeInterval);
  163. this.tps = !this.tps;
  164. GM.setValue("typesound", this.tps);
  165. }
  166.  
  167.  
  168. }
  169.  
  170. let btMuteSetting = await GM.getValue("bettermute");
  171. let typeSetting = await GM.getValue("typesound");
  172.  
  173. ig.game.settings.btm = typeof btMuteSetting == 'undefined' ? ig.game.settings.btm = false : ig.game.settings.btm = btMuteSetting;
  174. ig.game.settings.tps = typeof typeSetting == 'undefined' ? ig.game.settings.tps = false : ig.game.settings.tps = typeSetting;
  175. if(ig.game.settings.btm) {
  176. ig.game.settings.btm = !ig.game.settings.btm;
  177. ig.game.settings.betterMute();
  178.  
  179. }
  180.  
  181. if(ig.game.settings.tps) {
  182. ig.game.settings.tps = !ig.game.settings.tps;
  183. ig.game.settings.typeSound();
  184. }
  185.  
  186. // Making it compatiable with performance mod
  187. let splitCheck = ig.game.settings.openDialog.toString().split('function() {').length > 1 ? 'function() {' : 'function(){';
  188. let splitText = ig.game.settings.openDialog.toString().split(splitCheck)[1];
  189. let newFunction = splitText.split('a+="</div>";').join(`a += this.${ig.game.settings.header}("Sound Extras"); a += this.${ig.game.settings.add}("btm", "Better Mute", null, "ig.game.settings.betterMute()", this.btm); a += this.${ig.game.settings.add}("tps", "Typing Sound", null, "ig.game.settings.typeSound()", this.tps); a+="</div>";`)
  190.  
  191. eval('ig.game.settings.openDialog = function(){ ' + newFunction);
  192.  
  193. });
  194. }, 250)
  195. }()
  196. })();