Munzee Clanlink Replace

Replace Clanlinks

目前为 2019-11-10 提交的版本。查看 最新版本

// ==UserScript==
// @name         Munzee Clanlink Replace
// @namespace    https://gf.qytechs.cn/users/156194
// @version      0.4
// @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_option = GM_getValue('clanlink_option', 0);
        var clanlink_input = GM_getValue('clanlink_input', '');

        var page = document.getElementById('timezone');
        if(page) {
            function clanlink_input_speichern() {
                GM_setValue('clanlink_input', document.getElementById('clanlink_input').value);
            }
            function clanlink_option_aendern() {
                var clanlink_option_selected = document.getElementById('clanlink_option').value;
                GM_setValue('clanlink_option', clanlink_option_selected);
                if(clanlink_option_selected == 3) {
                    document.getElementById('clanlink_input_div').setAttribute('style', 'margin-bottom: 25px;');
                } else {
                    document.getElementById('clanlink_input_div').setAttribute('style', 'margin-bottom: 25px; display: none;');
                }
            }

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

            var clanlink_option0_selected = '';
            var clanlink_option1_selected = '';
            var clanlink_option2_selected = '';
            var clanlink_option3_selected = '';
            if(clanlink_option == 0) { clanlink_option0_selected = 'selected="selected"'; }
            if(clanlink_option == 1) { clanlink_option1_selected = 'selected="selected"'; }
            if(clanlink_option == 2) { clanlink_option2_selected = 'selected="selected"'; }
            if(clanlink_option == 3) { clanlink_option3_selected = 'selected="selected"'; }

            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="xxlInput">Clanlink Option</label><div class="input"><select name="clanlink_option" id="clanlink_option" class="form-control"><option value="0" ' + clanlink_option0_selected + '>Off (default link)</option><option value="1" ' + clanlink_option1_selected + '>Clan Stats by RUJA</option><option value="2" ' + clanlink_option2_selected + '>CuppaZee</option><option value="3" ' + clanlink_option3_selected + '>Own Clanlink</option></select></div></div><div class="clearfix col-xs-12 col-md-6 setting-box" id="clanlink_input_div" style="margin-bottom: 25px; display: none;"><label for="xlInput">Own Clanlink</label><div class="input"><input class="form-control" id="clanlink_input" name="clanlink_input" size="30" type="text" value="' + clanlink_input + '"></div></div>');

            document.getElementById('clanlink_option').addEventListener('change', clanlink_option_aendern, false);
            document.getElementById('clanlink_input').addEventListener('input', clanlink_input_speichern, false);
        } else {
            if(clanlink_option == 1 || clanlink_option == 2 || clanlink_option == 3) {
                var load_fancybox = 0;
                var clanlink_replace0 = document.querySelectorAll('a[href^="/clans/"]');
                for(var cr = 0, clanlink_replace; !!(clanlink_replace=clanlink_replace0[cr]); cr++) {
                    var link = '';
                    var teamname = '';
                    if(clanlink_option == 1) { // Clan Stats by RUJA
                        link = clanlink_replace.getAttribute('href');
                        if(link) {
                            teamname = link.split('/')[link.split('/').length - 2];
                            if(teamname) {
                                clanlink_replace.setAttribute('href', 'javascript:;');
                                clanlink_replace.setAttribute('title', 'Open Clanpage (external link)');
                                clanlink_replace.setAttribute('data-fancybox', '');
                                clanlink_replace.setAttribute('data-type', 'iframe');
                                clanlink_replace.setAttribute('data-src', 'http://www.munzeemeetsowl.de/redirect-clan.php?clan=' + teamname);
                                load_fancybox = 1;
                            }
                        }
                    } else {
                        if(clanlink_option == 2) { // CuppaZee
                            link = clanlink_replace.getAttribute('href');
                            if(link) {
                                teamname = link.split('/')[link.split('/').length - 2];
                                if(teamname) {
                                    clanlink_replace.setAttribute('href', 'javascript:;');
                                    clanlink_replace.setAttribute('title', 'Open Clanpage (external link)');
                                    clanlink_replace.setAttribute('data-fancybox', '');
                                    clanlink_replace.setAttribute('data-type', 'iframe');
                                    clanlink_replace.setAttribute('data-src', 'https://cuppazee.uk/clans/' + teamname);
                                    load_fancybox = 1;
                                }
                            }
                        } else { // Own Clanlink
                            clanlink_replace.setAttribute('href', 'javascript:;');
                            clanlink_replace.setAttribute('title', 'Open Clanpage (external link)');
                            clanlink_replace.setAttribute('data-fancybox', '');
                            clanlink_replace.setAttribute('data-type', 'iframe');
                            clanlink_replace.setAttribute('data-src', clanlink_input);
                            load_fancybox = 1;
                        }
                    }
                }

                if(load_fancybox == 1) {
                    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);
                }
            }
        }

    }


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

})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址