Eval Script

8/28/2022, 8:19:50 PM

目前为 2022-09-02 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Eval Script
  3. // @namespace Wolfy0615
  4. // @match https://mppclone.com/*
  5. // @match https://multiplayerpiano.com/*
  6. // @grant none
  7. // @version 1.3
  8. // @author Wolfy0615
  9. // @require https://greasyfork.org/scripts/450595-utilinspectforbrowser/code/UtilInspectForBrowser.js
  10. // @description 8/28/2022, 8:19:50 PM
  11. // ==/UserScript==
  12.  
  13. // Why the require? Minified code is scary.
  14. // Unminified code is avalible here: https://gist.github.com/Wolfy0615/e2617aca7cece2c2f067f3082fc37b5c?permalink_comment_id=4287505#gistcomment-4287505
  15. // Please note: Some function names etc. may seem odd, but the file is realitivly small. This module comes straight from NodeJS and was *compiled* for the browser.
  16. // This means I did not write that code myself, it was simply compiled to the file so it could work for the browser.
  17.  
  18. function handleMessage(msg) {
  19. let client = MPP.client;
  20. let token = localStorage.token;
  21. if (client) {
  22. if (msg.a.startsWith(">") && msg.p._id == client.getOwnParticipant()._id) {
  23. try {
  24. let localStorage = {};
  25. window.localStorage = {};
  26. let evaled = eval(msg.a.substring(1).trim());
  27. client.sendArray([{
  28. m: 'a',
  29. message: `✔️ ${typeof evaled} ${window.inspect(evaled)}`.substring(0, 512).replaceAll(token, "[REDACTED]").replaceAll("\n", " ")
  30. }])
  31. } catch (err) {
  32. if (err) {
  33. client.sendArray([{
  34. m: 'a',
  35. message: `❌ ${typeof err} ${err}`
  36. }]);
  37. }
  38. }
  39. }
  40. }
  41. }
  42. function init() {
  43. MPP.client.on("a", msg => { handleMessage(msg); });
  44. }
  45. const checkInterval = setInterval(() => {
  46. if (window.MPP) {
  47. clearInterval(checkInterval);
  48. init();
  49. }
  50. }, 200);