Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Speedometer
- // @version 0.3
- // @author Calculamatrise
- // @match *://www.freeriderhd.com/create/
- // @match *://www.freeriderhd.com/create
- // @match *://www.freeriderhd.com/t/*
- // @match *://frhd.kanoapps.com/create/
- // @match *://frhd.kanoapps.com/create
- // @match *://frhd.kanoapps.com/t/*
- // @downloadURL https://gist.githubusercontent.com/Calculamatrise/12c81637eb85b01835a77f0fb0d23370/raw/705083954d345f52048adb247084fbad3e71b32f/speedometer.frhd.js
- // @icon https://www.google.com/s2/favicons?domain=freeriderhd.com
- // @run-at document-idle
- // @grant none
- // ==/UserScript==
- let loaded = !1;
- GameManager.on('stateChange', state => {
- state.preloading === !1 && loaded === !1 && (loaded = !0);
- loaded && load()
- });
- window.hasOwnProperty('navigation') && navigation.addEventListener('navigate', () => loaded = !1, { passive: true });
- function load() {
- const draw = Object.getPrototypeOf(GameManager.game.currentScene).draw;
- GameManager.game.currentScene.draw = function(ctx = this.game.canvas.getContext("2d")) {
- draw.apply(this, arguments);
- const speed = (!GameManager.game.currentScene.playerManager.firstPlayer.isAlive() ? 0 : this.playerManager.firstPlayer._baseVehicle.speed) + " km/h";
- ctx.save();
- ctx.font = "20px Arial";
- ctx.fillStyle = (window.hasOwnProperty("lite") && 'light' !== lite.storage.get('theme')) ? "white" : "black";
- ctx.fillText(speed, this.game.canvas.width - ctx.measureText(speed).width - 10, this.game.canvas.height - 10);
- ctx.restore()
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement