Link Copier

Allows you to copy links that you normally wouldn't be able to copy from (i.e. Maze, FFA, ect..)

  1. // ==UserScript==
  2. // @name Link Copier
  3. // @namespace http://tampermonkey.net/
  4. // @version 1
  5. // @description Allows you to copy links that you normally wouldn't be able to copy from (i.e. Maze, FFA, ect..)
  6. // @author Someone
  7. // @match https://diep.io/
  8. // ==/UserScript==
  9.  
  10. var realSend = WebSocket.prototype.send;
  11. var mainWS;
  12. var serverWS;
  13. const URLRegex = /^wss?:\/\/[a-z0-9]{4}\.s\.m28n\.net\/$/g;
  14. let useServerFeatures = false;
  15.  
  16. WebSocket.prototype.send = function(data)
  17. {
  18. if (!(data instanceof Int8Array && this.url.match(URLRegex)) || this.dontRegister)
  19. {
  20. return realSend.call(this, data);
  21. }
  22.  
  23. if (this !== mainWS)
  24. {
  25. mainWS = this;
  26. this.serverID = this.url.split("://")[1].split(".")[0].toLowerCase();
  27. this.realRecv = this.onmessage;
  28. this.onmessage = function(event)
  29. {
  30. var data = new Uint8Array(event.data);
  31. switch (data[0])
  32. {
  33. case 4:
  34. {
  35. if (!this.partyCode) this.onmessage({data: [6]});
  36. break;
  37. }
  38. case 6:
  39. {
  40. if (window.location.hash && window.location.hash.indexOf("00") && window.location.hash.indexOf("00") + 2 !== window.location.hash.length)
  41. {
  42. this.partyCode = window.location.hash.slice(window.location.hash.indexOf("00") + 2).toUpperCase();
  43. }
  44. else
  45. {
  46. this.partyCode = Array.from(data).slice(1).map(r => r.toString(16).padStart(2, "0").split('').reverse().join("")).join("").toUpperCase();
  47. var x = this.partyCode;
  48. console.log(x)
  49. }
  50. if (useServerFeatures) serverWS.send("\x00" + this.serverID + "\x00" + this.partyCode);
  51. break;
  52. }
  53. }
  54. return this.realRecv.call(this, event);
  55. }
  56. }
  57. return realSend.call(this, data);
  58. }