Greasy Fork is available in English.

Kill counter

kill thingy

  1. // ==UserScript==
  2. // @name Kill counter
  3. // @namespace http://tampermonkey.net/
  4. // @version 3
  5. // @description kill thingy
  6. // @author MI300#4401
  7. // @match https://diep.io/*
  8. // @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
  9. // @license MIT
  10. // @grant none
  11. // ==/UserScript==
  12. function hook(target, callback){
  13. const check = () => {
  14. window.requestAnimationFrame(check)
  15. const func = CanvasRenderingContext2D.prototype[target]
  16.  
  17. if(func.toString().includes(target)){
  18.  
  19. CanvasRenderingContext2D.prototype[target] = new Proxy (func, {
  20. apply (method, thisArg, args) {
  21. callback(thisArg, args)
  22.  
  23. return Reflect.apply (method, thisArg, args)
  24. }
  25. });
  26. }
  27. }
  28. check()
  29. }
  30. let blacklist = new Array (0);
  31. let killCounter = 0;
  32. hook('fillText', function(thisArg, args){
  33. if (args[0].includes("You've killed ")) {
  34. if (blacklist.indexOf(args[0]) === -1) {
  35. killCounter+=1;
  36. blacklist.push (args[0])
  37. setTimeout (function() {
  38. blacklist.splice(blacklist.indexOf(args[0]), 1);
  39. },1000);
  40.  
  41. setTimeout (function() {
  42. blacklist.push(args[0]);
  43. },4600);
  44.  
  45. setTimeout (function() {
  46. blacklist.splice(blacklist.indexOf(args[0]), 1);
  47. },5000);
  48. }
  49. }
  50. })
  51. const canvas = document.getElementById('canvas')
  52. const ctx = canvas.getContext('2d');
  53. setInterval(() => {
  54. let gui = () => {
  55. ctx.fillStyle = "white";
  56. ctx.lineWidth = 7;
  57. ctx.font = 3 + "em Ubuntu";
  58. ctx.strokeStyle = "black";
  59. ctx.strokeText(`Kills: ` + killCounter, canvas.width * 0.9, canvas.height * 0.7);
  60. ctx.fillText(`Kills: ` + killCounter, canvas.width * 0.9, canvas.height * 0.7);
  61. window.requestAnimationFrame(gui);
  62. }
  63. gui();
  64. }, 1000);