Scenexe ignorer

adds the /ignore playerID and /unignore playerID commands to scenexe.

  1. // ==UserScript==
  2. // @name Scenexe ignorer
  3. // @namespace scenexeignorer
  4. // @description adds the /ignore playerID and /unignore playerID commands to scenexe.
  5. // @author discordtehe
  6. // @license MIT
  7. // @version 1.0.1
  8. // @grant none
  9. // @match https://scenexe.io
  10. // @match https://test.scenexe.io
  11. // @match https://new-test.scenexe.io
  12. // @match https://test2.scenexe.io
  13. // @require https://greasyfork.org/scripts/457386-scenexeutils/code/ScenexeUtils.js?version=1133496
  14. // @run-at document-start
  15. // ==/UserScript==
  16.  
  17. window.actionIgnore = function(action, playerID) {
  18. var data = JSON.parse(localStorage.getItem('ignored') || '{}');
  19. if (action == 'add') {
  20. data[playerID] = true;
  21. localStorage.setItem('ignored', JSON.stringify(data));
  22. } else if (action == 'remove') {
  23. delete data[playerID];
  24. localStorage.setItem('ignored', JSON.stringify(data));
  25. } else if (action == 'get') {
  26. return data;
  27. }
  28. }
  29.  
  30. window.modifyEvents = function(events) {
  31. const newEvents = [];
  32. for (var i = 0; i < events.length; i++) {
  33. var type = events[i][0];
  34. var content = events[i][1];
  35. var ignored = actionIgnore('get');
  36. if (type == 1) {
  37. if (content.id in ignored)
  38. continue;
  39. } else if (type == 12) {
  40. if (content[0] in ignored)
  41. continue;
  42. }
  43. newEvents.push(events[i]);
  44. }
  45. return newEvents;
  46. }
  47.  
  48. WebSocket.prototype.addEventListener = new Proxy(WebSocket.prototype.addEventListener, {
  49. apply: function (target, scope, args) {
  50. if (args[0] === 'message') {
  51. args[1] = new Proxy(args[1], {
  52. apply: function(ftarget, fscope, fargs) {
  53. var decoded = decode(new Uint8Array(fargs[0].data));
  54. if (decoded[0] == 0)
  55. decoded[1][10] = modifyEvents(decoded[1][10]);
  56. fargs[0] = new MessageEvent('message', {data: encode(decoded)})
  57. let fdata = ftarget.apply(fscope, fargs);
  58. return fdata;
  59. }
  60. })
  61. }
  62. let data = target.apply(scope, args);
  63. return data;
  64. }
  65. })
  66.  
  67. WebSocket.prototype.send = new Proxy(WebSocket.prototype.send, {
  68. apply: function (target, scope, args) {
  69. var packet = decode(new Uint8Array(args[0]));
  70. if (packet[0] == 4 && typeof packet[1] == 'string') {
  71. var temp = packet[1].split(' ');
  72. if (temp.length > 1 && temp[0] == '/ignore')
  73. actionIgnore('add', temp[1]);
  74. else if (temp.length > 1 && temp[0] == '/unignore')
  75. actionIgnore('remove', temp[1]);
  76. }
  77. let data = target.apply(scope, args);
  78. return data;
  79. }
  80. })