Restore Button Sanity

Restore undo & redo buttons to icons, fix the damn reload button to the correct icon

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name         Restore Button Sanity
// @namespace    https://greasyfork.org/users/30701-justins83-waze
// @version      0.1.03
// @description  Restore undo & redo buttons to icons, fix the damn reload button to the correct icon
// @author       JustinS83
// @include      https://www.waze.com/editor*
// @include      https://www.waze.com/*/editor*
// @include      https://beta.waze.com*
// @exclude      https://www.waze.com/user/editor*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    function bootstrap(tries) {
        tries = tries || 1;

        if (window.W &&
            window.W.map &&
            window.W.model &&
            window.W.loginManager.user &&
            $) {
            init();
        } else if (tries < 1000) {
            setTimeout(function () {bootstrap(tries++);}, 200);
        }
    }

    bootstrap();

    function init()
    {
        $('.waze-icon-reload').removeClass('reload');
        $('.waze-icon-reload span').addClass('fa fa-refresh fa-lg');
        $('.waze-icon-reload span')[0].innerHTML = "";

        $('.waze-icon-undo').removeClass('undo');
        $('.waze-icon-undo span').addClass('fa fa-undo fa-lg');
        $('.waze-icon-undo span')[0].innerHTML = "";

        $('.waze-icon-redo').removeClass('redo');
        $('.waze-icon-redo span').addClass('fa fa-repeat fa-lg');
        $('.waze-icon-redo span')[0].innerHTML = "";

        let extprovobserver = new MutationObserver(function(mutations) {
            mutations.forEach(function(mutation) {
                //console.log(mutation);
                if ($(mutation.target).hasClass('waze-icon-reload')){
                    $('.waze-icon-reload').removeClass('reload');
                    $('.waze-icon-reload span').addClass('fa fa-refresh fa-lg');
                    $('.waze-icon-reload span')[0].innerHTML = "";
                }
                else if($(mutation.target).hasClass('waze-icon-undo')){
                    $('.waze-icon-undo').removeClass('undo');
                    $('.waze-icon-undo span').addClass('fa fa-undo fa-lg');
                    $('.waze-icon-undo span')[0].innerHTML = "";
                }
                else if($(mutation.target).hasClass('waze-icon-redo')){
                    $('.waze-icon-redo').removeClass('redo');
                    $('.waze-icon-redo span').addClass('fa fa-repeat fa-lg');
                    $('.waze-icon-redo span')[0].innerHTML = "";
                }
            });
        });

        extprovobserver.observe(document.getElementById('edit-buttons'), { childList: true, subtree: true });
    }
})();