Diep.io Grayscale Theme

read the title

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Diep.io Grayscale Theme
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  read the title
// @author       bismuth
// @match        *diep.io
// @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant        none
// @license      none
// ==/UserScript==
['stroke','fill'].forEach(method => {
    CanvasRenderingContext2D.prototype[method] = new Proxy(CanvasRenderingContext2D.prototype[method], {
        apply: (target,_this,args) => {
            //console.log(_this.fillStyle);
            const fill = [parseInt(_this[`${method}Style`].slice(1,3), 16), parseInt(_this[`${method}Style`].slice(3,5), 16), parseInt(_this[`${method}Style`].slice(5,7), 16)];
            const grayscaleValue = ((((fill[0] << 4) - fill[0] + fill[1] + (fill[2] << 4)) >> 5) & 255).toString(16);
            _this[`${method}Style`] = `#${grayscaleValue}${grayscaleValue}${grayscaleValue}`;
            return Reflect.apply(target,_this,args);
        }
    });
});