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.

  1. // ==UserScript==
  2. // @name Extra Sound Settings
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.3
  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. // getPlayerChat depends on this
  22.  
  23.  
  24. }
  25.  
  26. async function main() {
  27. let btMuteSetting = await GM.getValue("bettermute");
  28. let typeSetting = await GM.getValue("typesound");
  29.  
  30. let pasteCheck = Deobfuscator.function(ig.game.player, 'Boolean(b&&b', true);
  31. let slotPass = Deobfuscator.object(ig.game, 'slots', true);
  32. let storedPasteCheck = ig.game.player[pasteCheck];
  33.  
  34.  
  35. ig.game.settings.add = Deobfuscator.function(ig.game.settings, 'Math.min(ig.system.scale,5)', true);
  36. ig.game.settings.header = Deobfuscator.function(ig.game.settings, 'text-transform: uppercase;', true);
  37. ig.game.settings.typeInterval = 1;
  38.  
  39.  
  40.  
  41.  
  42.  
  43. const getPlayerChat = target => {
  44. Deobfuscator.findByType = (object, type, returnKey) => {
  45.  
  46. let keyFound = null;
  47.  
  48. Object.keys(object).forEach((i) => {
  49. if (object[i] === null)
  50. return;
  51.  
  52. if (object[i].constructor === type)
  53. keyFound = returnKey ? i : object[i];
  54. });
  55.  
  56. return keyFound;
  57.  
  58. }
  59.  
  60. updatePlayers();
  61. if (ig.game.players.length == 0) return;
  62. let chat = "";
  63. ig.game.players.forEach(player => {
  64. let playerId = Deobfuscator.variableByLength(ig.game.players[1], 24, true)
  65. if (player[playerId] === target) {
  66.  
  67. let playerChat = Deobfuscator.object(player, 'player', false);
  68. playerChat.object = Deobfuscator.findByType(playerChat, Array, false);
  69.  
  70. if (playerChat.object.length != 0) {
  71. let index = playerChat.object.length - 1;
  72. chat = Deobfuscator.findByType(playerChat.object[index], String, false);
  73. }
  74. }
  75. });
  76.  
  77. return chat;
  78. }
  79.  
  80. function getDistance(x1, y1, x2, y2) {
  81. let xDistance = x2 - x1;
  82. let yDistance = y2 - y1;
  83.  
  84. return Math.sqrt(Math.pow(xDistance, 2) + Math.pow(yDistance, 2));
  85. }
  86.  
  87.  
  88. ig.game.settings.betterMute = function () {
  89. if (!this.btm) {
  90.  
  91. let whiteListedSounds = ["ping", "clap"];
  92. if (ig.game.settings.tps) whiteListedSounds.push("click");
  93.  
  94.  
  95. ig.game.player[pasteCheck] = function (a) {
  96. if (a === "mutesPastes") return true;
  97. var b = this.attachments[ig.game[slotPass].slots.WEARABLE];
  98.  
  99. return Boolean(b && b.attributes && b.attributes[a])
  100. }
  101.  
  102. for (let sound of Object.keys(ig.game.sounds)) {
  103. if (!whiteListedSounds.includes(sound)) {
  104. if (ig.game.sounds[sound].volume == 1) {
  105. ig.game.sounds[sound].volume = 0;
  106. }
  107.  
  108.  
  109. }
  110. }
  111. this.btm = !this.btm
  112. GM.setValue("bettermute", this.btm);
  113.  
  114. } else {
  115. ig.game.player[pasteCheck] = storedPasteCheck;
  116. for (let sound of Object.keys(ig.game.sounds)) {
  117. if (ig.game.sounds[sound].volume == 0) {
  118. ig.game.sounds[sound].volume = 1;
  119. }
  120.  
  121.  
  122. }
  123. this.btm = !this.btm;
  124. GM.setValue("bettermute", this.btm);
  125. }
  126.  
  127. }
  128.  
  129. ig.game.settings.typeSound = function () {
  130.  
  131. let chatBuffer = [{ id: "", message: "" }]
  132. let chatterIds = [""];
  133.  
  134. if (!this.tps) {
  135. ig.game.settings.typeInterval = setInterval(() => {
  136. updatePlayers();
  137. if (ig.game.players.length == 0) {
  138. this.tps = !this.tps;
  139. GM.setValue("typesound", this.tps);
  140. return;
  141. }
  142. for (let player of ig.game.players) {
  143.  
  144. let playerId = Deobfuscator.variableByLength(ig.game.players[1], 24, true)
  145.  
  146. 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) {
  147. if (!chatterIds.includes(player[playerId])) {
  148. chatBuffer.push({ id: player[playerId], message: getPlayerChat(player[playerId]) })
  149. chatterIds.push(player[playerId])
  150. }
  151.  
  152. for (let chatter of chatBuffer) {
  153. if (chatter.id === player[playerId]) {
  154.  
  155. if (chatter.message != getPlayerChat(player[playerId])) {
  156. ig.game.sounds.click.play();
  157. }
  158. chatter.message = getPlayerChat(player[playerId]);
  159.  
  160. }
  161. }
  162.  
  163. }
  164. }
  165. }, 50)
  166. this.tps = !this.tps;
  167. GM.setValue("typesound", this.tps);
  168.  
  169. } else {
  170. clearInterval(ig.game.settings.typeInterval);
  171. this.tps = !this.tps;
  172. GM.setValue("typesound", this.tps);
  173. }
  174.  
  175.  
  176. }
  177.  
  178.  
  179.  
  180. ig.game.settings.btm = typeof btMuteSetting == 'undefined' ? ig.game.settings.btm = false : ig.game.settings.btm = btMuteSetting;
  181. ig.game.settings.tps = typeof typeSetting == 'undefined' ? ig.game.settings.tps = false : ig.game.settings.tps = typeSetting;
  182.  
  183.  
  184. if (ig.game.settings.btm) {
  185. ig.game.settings.btm = !ig.game.settings.btm;
  186. ig.game.settings.betterMute();
  187.  
  188. }
  189.  
  190. if (ig.game.settings.tps) {
  191. ig.game.settings.tps = !ig.game.settings.tps;
  192. ig.game.settings.typeSound();
  193. }
  194.  
  195. // Making it compatiable with performance mod
  196. let splitCheck = ig.game.settings.openDialog.toString().split('function() {').length > 1 ? 'function() {' : 'function(){';
  197. let splitText = ig.game.settings.openDialog.toString().split(splitCheck)[1];
  198. 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>";`)
  199.  
  200. eval('ig.game.settings.openDialog = function(){ ' + newFunction);
  201. }
  202.  
  203. // Parses smooth loader
  204. !async function loader() {
  205. let loading = setInterval(async function () {
  206. if (typeof ig === "undefined") return
  207. else if (typeof ig.game === "undefined") return
  208. else if (typeof ig.game.screen === "undefined") return
  209. else if (ig.game.screen.x == 0) return
  210. else if (typeof Settings !== "function") return
  211.  
  212. clearInterval(loading);
  213. await loadObf();
  214. main();
  215. }, 250)
  216. }()
  217. })();