Update Free Rider Lite – New features!

Discussion in 'Third Party Scripting & Development' started by Calculus, Mar 28, 2020.

?

What do you think of this project?

  1. I love it!

  2. I’ll leave my response below.

Results are only viewable after voting.
  1. Wayward

    Wayward Well-Known Member Team Balloon Official Author

    Yes, the scripts themselves won't be terminated, they just won't work when Free Rider Lite is enabled. If you were to just disable the extension then the scripts would work perfectly fine.
     
    TheMemeBiker, AfterImage and Calculus like this.
  2. Fukase

    Fukase New Member

    prevented tracks from loading and crashed my browser.
     
  3. Calculus

    Calculus Community Developer Staff Member Administrator Ghost Moderator

    Awarded Medals
    The extension from the chrome webstore no longer works. You'll have to install it via GitHub if you want the functioning mod until I publish the new extension.
     
    AfterImage and TheMemeBiker like this.
  4. Calculus

    Calculus Community Developer Staff Member Administrator Ghost Moderator

    Awarded Medals
    Hey y'all,

    Major update in terms of performance and functionality: a lot of frhd-lite's features were taking away from the game's performance, and they weren't really contributing to anything. This update reduces poorly scripted code and improves the extension popup. All storage settings will now be saved in the extension. If you lose the extension, your settings will be reset. However, you can now change settings one other tabs. It is no longer restricted to Free Rider HD tabs. Updated settings will be applied to all Free Rider HD tabs. Clicking tracks should no longer trigger an endless loading screen. The issue may persist every now and then, but it's definitely a lot better; or it should be, at least.

    If you wish to install this version (v1.0.22), I believe you can download this zip then load unpacked extension via chrome://extensions after extracting its contents:
    https://github.com/Calculamatrise/frhd-lite/releases/tag/1.0.22

    Cheers
     
  5. AfterImage

    AfterImage Well-Known Member Team Balloon Official Author

    Awarded Medals
  6. Calculus

    Calculus Community Developer Staff Member Administrator Ghost Moderator

    Awarded Medals
    AfterImage and Trainer.John like this.
  7. Calculus

    Calculus Community Developer Staff Member Administrator Ghost Moderator

    Awarded Medals
    Next version will include a built-in offline editor, improved performance in terms of communication between the extension popup and the game, and reduced keybinding freedom (sorry not sorry, lol); instead of allowing y'all to see as many keys for a certain action, I find it's easier (for me) to only have a primary and a secondary key bind which can be changed and reset to their original state. Stay tuned!
     
  8. Methodical

    Methodical Well-Known Member Official Author

    Cough... is this available on edge... asking for a friend who plays frhd on microsoft edge like a noob. :omg:
     
    Cerasium likes this.
  9. Methodical

    Methodical Well-Known Member Official Author

  10. Calculus

    Calculus Community Developer Staff Member Administrator Ghost Moderator

    Awarded Medals
    That was in the very early stages of this extension. At a point where it was useless. This used to bring back the old theme if you didn't know already.
     
    Cerasium and Methodical like this.
  11. Calculus

    Calculus Community Developer Staff Member Administrator Ghost Moderator

    Awarded Medals
    Yes. It'll be available on just about anything that isn't safari.
     
    Cerasium and pawflix like this.
  12. ShadowMaster987

    ShadowMaster987 Active Member Team Balloon Official Author

    Calculus how do you use, i have the extension, just too dumb to know how to use
     
    Cerasium likes this.
  13. Calculus

    Calculus Community Developer Staff Member Administrator Ghost Moderator

    Awarded Medals
    Both existing extensions are outdated and likely broken. I can't take them down either. For now, you cannot use the mod as the current version has not been released.
     
    Cerasium, pawflix and Methodical like this.
  14. ShadowMaster987

    ShadowMaster987 Active Member Team Balloon Official Author

    oh ok
     
    Cerasium and Methodical like this.
  15. Calculus

    Calculus Community Developer Staff Member Administrator Ghost Moderator

    Awarded Medals
    Hey y'all,

    After rewriting a big portion of the frhd-lite extension, I decided to make an attempt at fixing the breaking of ghosts. A big issue with this bug is that we had no idea what was causing the ghosts to break; this means we were unable to reproduce it to delve deeper into the issue and find the root cause. However, after some testing, I concluded that ghosts were breaking as a result of the game losing focus. The game loses focus when you: switch tabs, windows, or maybe even click off of the main frame. I managed to consistently break my ghost several times, and after writing some code, I believe I did what had to be done to resolve the issue. Assuming the theory that the game losing its focus was not the only thing causing ghosts to break, I will need y'all to test it. Use the extension for a week or two. If any of your ghosts break, report back to me immediately! I would also advice that you make a post in this thread notifying other users that the anti-ghost-breaker feature is unsafe, and not ready for public use.

    To test this version of the mod, refer to the main post of this thread, and follow the steps on how to manually install the extension (this version is not live on the chrome webstore).

    Please note that I have changed a few property keys/names in the code, and some external scripts may not function properly with this version of Free Rider Lite. Heed my warning.
     
    Cerasium, pawflix, Totoca12 and 4 others like this.
  16. Wayward

    Wayward Well-Known Member Team Balloon Official Author

    Bucket fill?
     
    Cerasium likes this.
  17. Calculus

    Calculus Community Developer Staff Member Administrator Ghost Moderator

    Awarded Medals
    This really isn't the game for a fill tool since there's nothing I could fill in the space with aside from straight lines. Plus, it would probably be very heavy on your computer if you attempt to fill an area too large. I could add restrictions and prompts or whatnot to prevent that sort of thing from happening, but I really just don't want to create a bunch of lines grouped together at an inconsistent angle and position. But I just might.
     
  18. Calculus

    Calculus Community Developer Staff Member Administrator Ghost Moderator

    Awarded Medals
    I'll be adding a little list somewhere on the tracks page containing your top three incomplete daily achievements/tasks (the achievements you've completed the most) along with a timer to help you keep track of things. I may also allow users to create, and save tracks to playlists in a playlist tab under the user profile.
     
    Cerasium, Azgr00, Wayward and 3 others like this.
  19. Calculus

    Calculus Community Developer Staff Member Administrator Ghost Moderator

    Awarded Medals
    Here's a quick preview on a tampermonkey script I'm writing.
    upload_2023-6-18_16-34-21.png

    Users will be able to press on an achievement on the right to redirect them to a page where the achievement can be reached. If you clicked the first achievement listed, it would take you to a random track; the next one would search through your friends' recently ghosted tracks and go to one, etc.
    Preview Feature (open)
    Code:
    // ==UserScript==
    // @name         Achievements Display
    // @version      0.1
    // @author       Calculamatrise
    // @match        *://frhd.kanoapps.com/t/*
    // @match        *://www.freeriderhd.com/t/*
    // @grant        none
    // @run-at       document-start
    // ==/UserScript==
    
    {
        let achievements, countdown, countdownTimer;
        let container = createElement('div', {
            children: [
                createElement('a', {
                    children: [
                        createElement('span', {
                            innerText: 'Daily Achievements',
                            style: {
                                float: 'left'
                            }
                        }),
                        countdown = createElement('span', {
                            className: 'time-remaining',
                            innerText: '00:00:00',
                            style: {
                                float: 'right'
                            }
                        })
                    ],
                    href: '/achievements',
                    style: {
                        borderBottom: '1px solid gray',
                        color: 'white',
                        fontFamily: 'helsinki',
                        paddingBottom: '5px'
                    }
                }),
                achievements = createElement('div', {
                    id: 'achievements-container',
                    style: {
                        display: 'flex',
                        flexDirection: 'column',
                        fontFamily: 'riffic',
                        gap: '0.4rem'
                    }
                })
            ],
            className: 'simplemodal-container',
            style: {
                backgroundColor: 'rgb(27 82 100)',
                backgroundImage: 'linear-gradient(#1B5264,#143F4D)',
                borderRadius: '1rem',
                boxShadow: '0px 4px 8px 0px black',
                color: 'white',
                display: 'flex',
                flexDirection: 'column',
                gap: '0.6rem',
                margin: '0 10px',
                padding: '1.5rem',
                width: '-webkit-fill-available'
            }
        });
    
        refresh().then(function(response) {
            countdown.innerText = [String(Math.floor(response.time_left / 3600)).padStart(2, '0'), String(Math.floor((response.time_left % 3600) / 60)).padStart(2, '0'), String(Math.floor(response.time_left % 60)).padStart(2, '0')].join(':');
            countdownTimer = setInterval(function() {
                let lastTime = countdown.innerText.split(':').map(e => parseInt(e));
                if (lastTime[2] === 0) {
                    if (lastTime[1] === 0) {
                        lastTime[0]--;
                        lastTime[1] = 59;
                    }
    
                    lastTime[1]--;
                    lastTime[2] = 59;
                }
    
                lastTime[2]--;
                lastTime.reduce((sum, remainingTime) => sum += remainingTime, 0) === 0 && clearInterval(countdownTimer);
                countdown.innerText = lastTime.map(e => String(e).padStart(2, '0')).join(':');
            }, 1e3)
    
            waitForElm('#right_content').then((elm) => {
                elm.prepend(container);
            });
        });
    
        addEventListener('load', function() {
            Application.events.subscribe('mainview.loaded', function() {
                waitForElm('#right_content').then((elm) => {
                    elm.prepend(container);
                });
            });
            // Application.events.subscribe('refresh', load);
            Application.Helpers.AjaxHelper._check_event_notification = function(e) {
                Object.getPrototypeOf(Application.Helpers.AjaxHelper)._check_event_notification.apply(this, arguments);
                if ("undefined" != typeof e.data && ("undefined" != typeof e.data.achievements_earned)) {
                    Application.events.publish("achievementsEarned", e.data.achievements_earned);
                    refresh(); // add animation? // refresh everything
                }
    
                // console.log("other", e);
                refresh() // only update percentages
            }
        });
    
        function refresh() {
            return fetch("/achievements?ajax").then(r => r.json()).then(function(response) {
                achievements.replaceChildren(...response.achievements.filter(a => !a.complete).sort((a, b) => b.tot_num - a.tot_num).slice(0, 3).map(createProgressElement));
                return response;
            });
        }
    }
    
    function createElement(type, options) {
        const callback = arguments[arguments.length - 1];
        const element = document.createElement(type);
        if ('innerText' in options) {
            element.innerText = options.innerText;
            delete options.innerText;
        }
    
        for (const attribute in options) {
            if (typeof options[attribute] == 'object') {
                if (options[attribute] instanceof Array) {
                    if (/^children$/i.test(attribute)) {
                        element.append(...options[attribute]);
                    } else if (/^on/i.test(attribute)) {
                        for (const listener of options[attribute]) {
                            element.addEventListener(attribute.slice(2), listener);
                        }
                    }
                } else if (/^style$/i.test(attribute)) {
                    Object.assign(element[attribute.toLowerCase()], options[attribute]);
                }
    
                delete options[attribute];
            }
        }
    
        Object.assign(element, options);
        return typeof callback == 'function' && callback(element), element;
    }
    
    function createProgressElement(achievement) {
        let container = createElement('div', {
            children: [
                createElement('a', {
                    children: [
                        createElement('b', {
                            innerText: achievement.title
                        }),
                        createElement('h6', {
                            innerText: achievement.desc,
                            style: {
                                color: 'darkgray',
                                fontFamily: 'roboto_bold',
                                margin: 0
                            }
                        })
                    ],
                    href: '',
                    style: {
                        width: '-webkit-fill-available'
                    }
                }),
                // achievement.coins
                createElement('span', {
                    innerText: achievement.current, // achievement.progress // achievement.current + '/' + achievement.max
                    style: {
                        fontFamily: 'helsinki',
                        fontSize: '2rem'
                    }
                })
            ],
            style: {
                display: 'flex',
                gap: '0.25rem'
            }
        });
    
        return container;
    }
    
    function waitForElm(selector) {
        return new Promise(resolve => {
            if (document.querySelector(selector)) {
                return resolve(document.querySelector(selector));
            }
    
            const observer = new MutationObserver(mutations => {
                if (document.querySelector(selector)) {
                    resolve(document.querySelector(selector));
                    observer.disconnect();
                }
            });
    
            observer.observe(document.body, {
                childList: true,
                subtree: true
            });
        });
    }
     
    Last edited: Jun 20, 2023
  20. FIREBEATS

    FIREBEATS FRHD Member of 2020 Team Helicopter Official Author

    Who needs Kano Developers we have you :)
     
    Cerasium and Azgr00 like this.

Share This Page