Scenexe ignorer

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

You will need to install an extension such as Tampermonkey to install this script.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name     Scenexe ignorer
// @namespace   scenexeignorer
// @description adds the /ignore playerID and /unignore playerID commands to scenexe.
// @author    discordtehe
// @license  MIT
// @version  1.0.1
// @grant    none
// @match     https://scenexe.io
// @match     https://test.scenexe.io
// @match     https://new-test.scenexe.io
// @match     https://test2.scenexe.io
// @require   https://greatest.deepsurf.us/scripts/457386-scenexeutils/code/ScenexeUtils.js?version=1133496
// @run-at   document-start
// ==/UserScript==

window.actionIgnore = function(action, playerID) {
    var data = JSON.parse(localStorage.getItem('ignored') || '{}');
    if (action == 'add') {
        data[playerID] = true;
        localStorage.setItem('ignored', JSON.stringify(data));
    } else if (action == 'remove') {
        delete data[playerID];
        localStorage.setItem('ignored', JSON.stringify(data));
    } else if (action == 'get') {
        return data;
    }
}

window.modifyEvents = function(events) {
    const newEvents = [];
    for (var i = 0; i < events.length; i++) {
      var type = events[i][0];
      var content = events[i][1];
      var ignored = actionIgnore('get');
      if (type == 1) {
          if (content.id in ignored)
              continue;
      } else if (type == 12) {
          if (content[0] in ignored)
              continue;
      }
      newEvents.push(events[i]);
    }
    return newEvents;
}

WebSocket.prototype.addEventListener = new Proxy(WebSocket.prototype.addEventListener, {
    apply: function (target, scope, args) {
        if (args[0] === 'message') {
            args[1] = new Proxy(args[1], {
                apply: function(ftarget, fscope, fargs) {
                    var decoded = decode(new Uint8Array(fargs[0].data));
                    if (decoded[0] == 0)
                        decoded[1][10] = modifyEvents(decoded[1][10]);
                    fargs[0] = new MessageEvent('message', {data: encode(decoded)})
                    let fdata = ftarget.apply(fscope, fargs);
                    return fdata;
                }
            })
        }
        let data = target.apply(scope, args);
        return data;
    }
})

WebSocket.prototype.send = new Proxy(WebSocket.prototype.send, {
    apply: function (target, scope, args) {
        var packet = decode(new Uint8Array(args[0]));
        if (packet[0] == 4 && typeof packet[1] == 'string') {
            var temp = packet[1].split(' ');
            if (temp.length > 1 && temp[0] == '/ignore')
                actionIgnore('add', temp[1]);
            else if (temp.length > 1 && temp[0] == '/unignore')
                actionIgnore('remove', temp[1]);
        }
        let data = target.apply(scope, args);
        return data;
    }
})