Replace Clanlinks
当前为
// ==UserScript==
// @name Munzee Clanlink Replace
// @namespace https://greasyfork.org/users/156194
// @version 0.6
// @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_firstrun = GM_getValue('clanlink_firstrun', 1);
if(clanlink_firstrun == 1) {
function clanlink_firstrun_button0() {
GM_setValue('clanlink_option', 0);
GM_setValue('clanlink_firstrun', 0);
location.reload();
}
function clanlink_firstrun_button1() {
GM_setValue('clanlink_option', 1);
GM_setValue('clanlink_firstrun', 0);
location.reload();
}
function clanlink_firstrun_button2() {
GM_setValue('clanlink_option', 2);
GM_setValue('clanlink_firstrun', 0);
location.reload();
}
function clanlink_firstrun_button3() {
document.getElementById('clanlink_firstrun_input').setAttribute('style', 'display: inline;width: 200px;color: #000;padding: 5px;border-radius: 10px;font-style: normal;');
var input_value = document.getElementById('clanlink_firstrun_input').value;
GM_setValue('clanlink_option', 3);
GM_setValue('clanlink_input', input_value);
GM_setValue('clanlink_firstrun', 0);
if(input_value != 'https://') location.reload();
}
document.body.insertAdjacentHTML('afterbegin', '<div style="position: fixed;left: 0px;top: 0px;height: 100%;width: 100%;background-color: black;opacity: 0.9;z-index: 9999;text-align: center;font-family: Ubuntu,sans-serif;font-weight: 400;font-style: italic;color: #fff;"><div style="margin: 50px;font-style: normal;font-size: x-large;">Munzee Clanlink Replace</div><div style="margin: 50px;color: white;font-size: larger;">Welcome, this script will change the clanlink<br>at the profile page. Please choose an option.<br><br>You can change it whenever you want<br>at your <a href="https://www.munzee.com/settings" style="color: #fff;">profile settings</a> page.</div><div><button id="clanlink_firstrun_button0" class="user-stat stat-green" style="width: 200px;padding-top: 0px;border-radius: 10px !important;margin-bottom: 15px;">Off (default link)</button><br><button id="clanlink_firstrun_button1" class="user-stat stat-green" style="width: 200px;padding-top: 0px;border-radius: 10px !important;margin-bottom: 15px;">Clan Stats by RUJA</button><br><button id="clanlink_firstrun_button2" class="user-stat stat-green" style="width: 200px;padding-top: 0px;border-radius: 10px !important;margin-bottom: 15px;">CuppaZee</button><br><button id="clanlink_firstrun_button3" class="user-stat stat-green" style="width: 200px;padding-top: 0px;border-radius: 10px !important;margin-bottom: 15px;">Own Clanlink</button><br><input type="text" id="clanlink_firstrun_input" name="clanlink_firstrun_input" size="30" value="https://" style="display: none;"></div></div>');
document.getElementById('clanlink_firstrun_button0').addEventListener('click', clanlink_firstrun_button0, false);
document.getElementById('clanlink_firstrun_button1').addEventListener('click', clanlink_firstrun_button1, false);
document.getElementById('clanlink_firstrun_button2').addEventListener('click', clanlink_firstrun_button2, false);
document.getElementById('clanlink_firstrun_button3').addEventListener('click', clanlink_firstrun_button3, false);
document.getElementById('clanlink_firstrun_input').addEventListener('change', clanlink_firstrun_button3, false);
} else {
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 = '';
var clanlink_input_style = 'display: none;';
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"'; clanlink_input_style = ''; }
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; ' + clanlink_input_style + '"><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', 'https://stats.munzee.dk/?clan_name=' + 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);
}
})();