MPP Chat Eval

Send result of "> input" to chat

  1. // ==UserScript==
  2. // @name MPP Chat Eval
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.1
  5. // @description Send result of "> input" to chat
  6. // @author MPP Firefox
  7. // @license MIT
  8. // @match https://multiplayerpiano.com/*
  9. // @match https://mppclone.com/*
  10. // @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
  11. // @grant none
  12. // ==/UserScript==
  13.  
  14. const _ce_init = () => {
  15. MPP.client.on('a', e => {
  16. if (e.p._id === MPP.client.getOwnParticipant()._id && e.a.indexOf("> ") === 0) {
  17. let thing;
  18. try {
  19. thing = eval(e.a.substr(2));
  20. } catch(err) { thing = err.message.toString() }
  21.  
  22. MPP.client.sendArray([{m: "a", message: thing.toString()}]);
  23. }
  24. });
  25. }
  26.  
  27. const _ce_mppExists = time => {
  28. if (window.MPP === undefined) requestAnimationFrame(_ce_mppExists); else _ce_init();
  29. }
  30.  
  31. requestAnimationFrame(_ce_mppExists);