Advertisement
Guest User

Untitled

a guest
Aug 20th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.11 KB | None | 0 0
  1. // ==UserScript==
  2. // @name Jstris TGM Sounds
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.3
  5. // @description adds tgm sounds for jstris
  6. // @author NueSB
  7. // @match https://*.jstris.jezevec10.com/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13. window.addEventListener('load', function() {
  14. /*
  15. Game["prototype"]["moveCurrentBlock"] = function(_0xb09ex34, _0xb09ex35, _0xb09ex36) {
  16. if (!_0xb09ex35) {
  17. this["finesse"]++
  18. };
  19. _0xb09ex34 *= this["blockSets"][this["activeBlock"]["set"]]["step"];
  20. if (!this["checkIntersection"](this["activeBlock"]["pos"]["x"] + _0xb09ex34, this["activeBlock"]["pos"]["y"], null)) {
  21. this["activeBlock"]["pos"]["x"] = this["activeBlock"]["pos"]["x"] + _0xb09ex34;
  22. this["lastAction"] = _0xb09ex36;
  23. this["updateGhostPiece"](true);
  24. this["redraw"]();
  25. this["playSound"]("move")
  26. return true
  27. };
  28. return false
  29. };*/
  30.  
  31. let pieceSounds = {};
  32. let srcs = {
  33. 0: "https://cdn.discordapp.com/attachments/235512056588140546/557815203677470730/SEB_mino7.wav",
  34. 1: "https://cdn.discordapp.com/attachments/235512056588140546/557815184010379264/SEB_mino1.wav",
  35. 2: "https://cdn.discordapp.com/attachments/235512056588140546/557815201324335104/SEB_mino6.wav",
  36. 3: "https://cdn.discordapp.com/attachments/235512056588140546/557815194756317184/SEB_mino3.wav",
  37. 4: "https://cdn.discordapp.com/attachments/235512056588140546/557815192033951745/SEB_mino2.wav",
  38. 5: "https://cdn.discordapp.com/attachments/235512056588140546/557815199294291971/SEB_mino5.wav",
  39. 6: "https://cdn.discordapp.com/attachments/235512056588140546/557815196920578058/SEB_mino4.wav",
  40. 7: "https://cdn.discordapp.com/attachments/235512056588140546/558050338188558336/ITEM01.wav"
  41. };
  42. function playSound(s) {
  43. if (!s.paused && s.currentTime > 0) {
  44. s.currentTime = 0;
  45. } else s.play();
  46. }
  47.  
  48. function initSounds(dest, srclist) {
  49. for (let i in srclist) {
  50. dest[i] = document.createElement("audio");
  51. dest[i].src = srclist[i];
  52. dest[i].volume = 0.1;
  53. }
  54. }
  55.  
  56. function TGMSound(id) {
  57. if (pieceSounds[id] === undefined)
  58. {
  59. playSound(pieceSounds[id % 7]);
  60. return;
  61. }
  62. playSound(pieceSounds[id]);
  63. }
  64. initSounds(pieceSounds, srcs);
  65.  
  66. Game["prototype"]["updateQueueBox"] = function() {
  67. if (!this["ISGAME"] && (this["v"]["redrawBlocked"] || !this["v"]["QueueHoldEnabled"])) {
  68. return
  69. };
  70. this["v"]["clearQueueCanvas"]();
  71. TGMSound(this.queue[0].id);
  72. if (Math.floor(Math.random() * 3) === 3) playSound(pieceSounds[7]);
  73. let _0xb09ex106 = 0;
  74. for (var _0xb09exc = 0; _0xb09exc < this["showPreviews"]; _0xb09exc++) {
  75. if (_0xb09exc >= this["queue"]["length"]) {
  76. break
  77. };
  78. var _0xb09exdd = this["queue"][_0xb09exc];
  79. var _0xb09ex2d = this["blockSets"][_0xb09exdd["set"]]["previewAs"],
  80. _0xb09ex2e = _0xb09ex2d["blocks"][_0xb09exdd["id"]]["blocks"][0],
  81. _0xb09ex107 = _0xb09ex2d["blocks"][_0xb09exdd["id"]]["color"],
  82. _0xb09ex108 = (!_0xb09ex2d["equidist"]) ? _0xb09ex2d["blocks"][_0xb09exdd["id"]]["yp"] : [0, 3],
  83. _0xb09ex2f = _0xb09ex2e["length"],
  84. _0xb09ex109 = (_0xb09ex2d["blocks"][_0xb09exdd["id"]]["xp"]) ? _0xb09ex2d["blocks"][_0xb09exdd["id"]]["xp"] : [0, _0xb09ex2f - 1];
  85. for (var _0xb09ex10 = _0xb09ex108[0]; _0xb09ex10 <= _0xb09ex108[1]; _0xb09ex10++) {
  86. for (var _0xb09ex11 = _0xb09ex109[0]; _0xb09ex11 <= _0xb09ex109[1]; _0xb09ex11++) {
  87. if (_0xb09ex2e[_0xb09ex10][_0xb09ex11] === 1) {
  88. this["v"]["drawBlockOnCanvas"](_0xb09ex11 - _0xb09ex109[0], _0xb09ex10 - _0xb09ex108[0] + _0xb09ex106, _0xb09ex107, this["v"].QUEUE)
  89. }
  90. }
  91. };
  92. if (_0xb09ex2d["equidist"]) {
  93. _0xb09ex106 += 3
  94. } else {
  95. _0xb09ex106 += _0xb09ex108[1] - _0xb09ex108[0] + 2
  96. }
  97. }
  98. };
  99. })();
  100. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement