Munzee Clanlink Replace

Replace Clanlinks

Fra og med 09.11.2019. Se den nyeste version.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

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.

(I already have a user style manager, let me install it!)

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

})();