Supremacy1914 AD blocker

AD = cancer, Script can may soon be obsolete

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name Supremacy1914 AD blocker
// @namespace http://tampermonkey.net/
// @version 1.5
// @description AD = cancer, Script can may soon be obsolete
// @author Somka
// @match *://www.supremacy1914.pl/*
// @match *://pl.callofwar.com/*
// @match *://www.callofwar.com/*
// @match *://www.callofwar.fr/*
// @match *://www.callofwar.de/*
// @match *://www.callofwar.ru/*
// @match *://www.callofwar.nl/*
// @match *://www.callofwar.es/*
// @match *://www.callofwar.it/*
// @match *://www.supremacy1914.com/*
// @match *://www.supremacy1914.fr/*
// @match *://www.supremacy1914.de/*
// @match *://www.supremacy1914.ru/*
// @match *://www.supremacy1914.nl/*
// @match *://www.supremacy1914.es/*
// @match *://www.supremacy1914.it/*
// @match *://www.callofwar.pl/*
// @icon https://www.magnum-x.pl/files/2018/TWH/SP-5-2018/6.jpg
// @license CC BY-NC-ND
// @grant GM_getValue
// @grant GM_setValue
// @grant GM_removeValueChangeListener
// ==/UserScript==

(function() {
'use strict';
function toggleAdMode() {
var element = document.getElementById("ultimate");
if (element) {
element.setAttribute("data-ad-mode", "false"); //no more auto-enabling ad mode
}
}

function rmAdBar() {
var ifm = document.getElementById('ifm');
if (ifm && ifm.contentDocument) {
var inGameAdsContainer = ifm.contentDocument.getElementById('inGameAdsContainer'); //ad bar
if (inGameAdsContainer) {
inGameAdsContainer.parentNode.removeChild(inGameAdsContainer);
var s1914 = ifm.contentDocument.getElementById('s1914');
}
}

// pain
var elements = document.querySelectorAll('img[src*="static1.bytro.com/fileadmin/templates"]'); //ads pics sup
for (var i = 0; i < elements.length; i++) {
elements[i].parentNode.removeChild(elements[i]);
}
var elements = document.querySelectorAll('img[src*="//www.callofwar.com/clients/ww2-uber"]'); //ads pics cow
for (var i = 0; i < elements.length; i++) {
elements[i].parentNode.removeChild(elements[i]);
}
}
var intervalId = window.setInterval(function chrono() {
  rmAdBar();
  toggleAdMode();
}, 100);

var url = document.location.href;
var addresses = [ 'www.supremacy1914.pl/play.php?', 'www.supremacy1914.fr/play.php?', 'www.supremacy1914.it/play.php?', 'www.supremacy1914.es/play.php?', 'www.supremacy1914.com/play.php?', 'www.supremacy1914.nl/play.php?', 'www.supremacy1914.de/play.php?', 'www.supremacy1914.ru/play.php?', 'www.callofwar.com/play.php?', 'www.callofwar.fr/play.php?', 'www.callofwar.nl/play.php?', 'www.callofwar.de/play.php?', 'www.callofwar.ru/play.php?', 'www.callofwar.pl/play.php?', 'www.callofwar.es/play.php?', 'www.callofwar.it/play.php?']

for (var i = 0; i < addresses.length; i++) {
if (url.indexOf(addresses[i]) > -1) {
chrono();
break;
}
}
})();