Used to edit the canvas in diep.io. You can use it in your tampermonkey script like so:
// @require https://raw.githubusercontent.com/endless7z/Diep.io-Canvas-Hook/main/canvas-hook.js
A list of events to listen for can be acquired using this code snippet:
Object.keys(CanvasRenderingContext2D.prototype);
Then,
const Canvas = new CanvasHook();
Canvas.on(YOUR_EVENT, event => {
...
});
Replace all text with "lol"
const Canvas = new CanvasHook();
Canvas.on(['fillText', 'strokeText'], text => {
text.arguments[0] = 'lol'; // replaces all text with "lol"
});
Change the stroke color of everything to red
const Canvas = new CanvasHook();
Canvas.on('stroke', text => {
text.element.strokeStyle = '#FF0000'; // turns stuff red
});