Munzee Clanlink Replace

Replace Clanlinks

Verze ze dne 09. 11. 2019. Zobrazit nejnovější verzi.

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

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

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         Munzee Clanlink Replace
// @namespace    https://greasyfork.org/users/156194
// @version      0.3
// @description  Replace Clanlinks
// @author       rabe85
// @match        https://www.munzee.com/m/*/*
// @match        https://www.munzee.com/settings
// @match        https://www.munzee.com/settings/*
// @grant        GM_setValue
// @grant        GM_getValue
// @grant        GM_deleteValue
// ==/UserScript==

(function() {
    'use strict';

    function munzee_clanlink_replace() {

        var clanlink = GM_getValue('clanlink', '');

        var page = document.getElementById('timezone');
        if(page) {
            function clanlink_speichern() {
                GM_setValue('clanlink', document.getElementById('clanlink').value);
            }

            document.getElementById('distance_type').parentElement.parentElement.setAttribute('style', 'margin-bottom: 10px;');

            var pos = document.getElementById('email_address').parentElement.parentElement;
            pos.setAttribute('style', 'margin-bottom: 10px;');
            pos.insertAdjacentHTML('afterend', '<div class="clearfix col-xs-12 col-md-6 setting-box" style="margin-bottom: 25px;"><label for="xlInput">Clanlink (Automatic, if empty)</label><div><input class="form-control" id="clanlink" name="clanlink" size="30" type="text" value="' + clanlink + '"></div></div>');

            document.getElementById('clanlink').addEventListener('input', clanlink_speichern, false);
        } else {
            var load_fancybox_css = document.createElement('link');
            load_fancybox_css.rel = 'StyleSheet';
            load_fancybox_css.type = 'text/css';
            load_fancybox_css.href = 'https://cdnjs.cloudflare.com/ajax/libs/fancybox/3.5.7/jquery.fancybox.min.css';
            document.head.appendChild(load_fancybox_css);

            var load_fancybox_script = document.createElement('script');
            load_fancybox_script.src = 'https://cdnjs.cloudflare.com/ajax/libs/fancybox/3.5.7/jquery.fancybox.min.js';
            document.body.appendChild(load_fancybox_script);

            var clanlink_replace0 = document.querySelectorAll('a[href^="/clans/"]');
            for(var cr = 0, clanlink_replace; !!(clanlink_replace=clanlink_replace0[cr]); cr++) {
                clanlink_replace.setAttribute('data-fancybox', '');
                clanlink_replace.setAttribute('data-type', 'iframe');
                clanlink_replace.setAttribute('href', 'javascript:;');
                clanlink_replace.setAttribute('title', 'Open Clanpage (external link)');
                if(clanlink) {
                    clanlink_replace.setAttribute('data-src', clanlink);
                } else {
                    var link = clanlink_replace.getAttribute('href');
                    if(link) {
                        var teamname = link.split('/')[link.split('/').length - 2];
                        if(teamname) {
                            clanlink_replace.setAttribute('data-src', 'http://www.munzeemeetsowl.de/redirect-clan.php?clan=' + teamname);
                        }
                    }
                }
            }
        }

    }


    // DOM vollständig aufgebaut?
    if (/complete|interactive|loaded/.test(document.readyState)) {
        munzee_clanlink_replace();
    } else {
        document.addEventListener("DOMContentLoaded", munzee_clanlink_replace, false);
    }

})();