Munzee Clanlink Replace

Replace Clanlinks

Versione datata 09/11/2019. Vedi la nuova versione l'ultima versione.

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

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

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==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);
    }

})();