(function() {
//console.log("MS: Init");
let timeStart = 0;
if (document.msppID) {
if (!'.mmedee') {
document.write('
');
}
//console.log("MS: Существует переменная msppID");
return;
}
let Id = "block-" + Date.now();
document.msppID = Id
if (!'.mmedee') {
document.write('');
}
const errNotBlock = 1
let MD5 = function(d){var r = M(V(Y(X(d),8*d.length)));return r.toLowerCase()};function M(d){for(var _,m="0123456789ABCDEF",f="",r=0;r>>4&15)+m.charAt(15&_);return f}function X(d){for(var _=Array(d.length>>2),m=0;m<_.length;m++)_[m]=0;for(m=0;m<8*d.length;m+=8)_[m>>5]|=(255&d.charCodeAt(m/8))<>5]>>>m%32&255);return _}function Y(d,_){d[_>>5]|=128<<_%32,d[14+(_+64>>>9<<4)]=_;for(var m=1732584193,f=-271733879,r=-1732584194,i=271733878,n=0;n>16)+(_>>16)+(m>>16)<<16|65535&m}function bit_rol(d,_){return d<<_|d>>>32-_}
const rnd = MD5(Date.now() + ':' + Math.random() + ':' +location.href);
let params = {
apiKey: '1ce581b8e0f2fe911a7b0868fc3c0c9b',
utmSource: '',
utmCampaign: '',
utmMedium: '',
utmContent: '',
utmClickId: '',
sourceName: '',
sourceURL: '',
sourceIntro: '',
sourceNote: '',
priority: 'source',
slug: {},
tag: '',
tagSelector: '#post-329 > div > div > p:nth-child(24) > a',
tagSelector2: '',
outputSelector: '.mmedee' ? '.mmedee' : '#main_' + Id,
addToAll: 1,
btnPosition: 'beforeend',
ifNotFoundThenDefault: 0,
landPage: 0,
bl: 0
};
function MSetup() {
//console.log("MS: Start");
if (!Element.prototype.closest) {
if (!Element.prototype.matches) {
Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector;
}
Element.prototype.closest = function (s) {
var el = this;
var ancestor = this;
if (!document.documentElement.contains(el)) return null;
do {
if (ancestor.matches(s)) return ancestor;
ancestor = ancestor.parentElement;
} while (ancestor !== null);
return null;
};
}
let browserName = (function (agent) {
switch (true) {
case agent.indexOf("edge") > -1:
return "MS Edge";
case agent.indexOf("edg/") > -1:
return "Edge (chromium based)";
case agent.indexOf("opr") > -1 && !!window.opr:
return "Opera";
case agent.indexOf("chrome") > -1 && !!window.chrome:
return "Chrome";
case agent.indexOf("trident") > -1:
return "MS IE";
case agent.indexOf("firefox") > -1:
return "Mozilla Firefox";
case agent.indexOf("safari") > -1:
return "Safari";
default:
return "other";
}
})(window.navigator.userAgent.toLowerCase());
if (browserName !== 'MS IE' && window.XMLHttpRequest.prototype.open) {
let openFunction = window.XMLHttpRequest.prototype.open.toString();
if (openFunction.indexOf('native code') === -1) {
params.bl = 1
}
}
function getData(url, option, callback, noFound) {
//console.log("MS: getData");
//console.log(url);
try {
let xhr = new XMLHttpRequest();
xhr.open("GET", url);
xhr.onreadystatechange = function() {
if(xhr.readyState === 4 && xhr.status === 0){
sendErrorMSPP(new SyntaxError("Blocker exists"), url)
}
};
xhr.addEventListener("load", function () {
let responseText = '';
try {
if (xhr.status !== 200) {
//console.log('MSetup: '+xhr.status + ": " + xhr.statusText);
sendErrorMSPP(new SyntaxError("ajax status not is 200"), xhr.status + ": " + xhr.statusText)
if (typeof noFound === "function") {
noFound();
}
} else {
if (option && xhr.responseText != null && xhr.responseText !== "") {
responseText = xhr.responseText;
params[option] = JSON.parse(responseText);
}
if (xhr.responseText &&
xhr.responseText !== "-" &&
params[option] !== null &&
typeof callback === "function"
) {
callback();
} else {
if (typeof noFound === "function") {
noFound();
}
}
}
} catch(e) {
sendErrorMSPP(e, responseText+' '+typeof xhr.responseText+' '+url)
}
})
xhr.send();
} catch(e) {
sendErrorMSPP(e)
}
}
function addStyle() {
try {
let styles =
'"
document.body.insertAdjacentHTML("afterbegin", styles);
} catch(e) {
sendErrorMSPP(e)
}
}
window.goNextPage = function (slug, elem) {
try {
if (typeof window.callbackMSPPClick == "function") {
window.callbackMSPPClick()
}
if (!elem) {
//console.log("MSetup: не найден элемент")
return;
}
let el = elem.closest(params.outputSelector);
if (el == null) {
sendErrorMSPP(new SyntaxError("No parent element"), params.outputSelector + ' ' + elem.getAttribute('class'))
return;
}
getDataAttr(el);
let path = params.slug.domain + "api/getbundle/";
if (params.landPage === 1) {
path = "https://download-msetup.org/land/page/";
}
let batchId = 0
if (el.dataset.batch_id != null) {
batchId = el.dataset.batch_id
}
let url = path +
"?partner_apikey=" +
encodeURIComponent(params.apiKey) +
"&r=" +
encodeURIComponent(rnd) +
"&bl=" +
encodeURIComponent(params.bl) +
"&b=" +
encodeURIComponent(batchId) +
"&program_slug=" +
encodeURIComponent(slug) +
"&utm_term=" +
encodeURIComponent(slug) +
"&utm_campaign=" +
encodeURIComponent(params.utmCampaign) +
"&utm_source=" +
encodeURIComponent(params.utmSource) +
"&utm_medium=" +
encodeURIComponent(params.utmMedium) +
"&utm_content=" +
encodeURIComponent(params.utmContent) +
"&utm_clickid=" +
encodeURIComponent(params.utmClickId) +
"&sourceURL=" +
encodeURIComponent(params.sourceURL) +
"&sourceName=" +
encodeURIComponent(params.sourceName) +
"&sourceIntro=" +
encodeURIComponent(params.sourceIntro) +
"&sourceNote=" +
encodeURIComponent(params.sourceNote) +
"&rfr=" +
encodeURIComponent(location.href);
let windowObjectReference = window.open(url, "_blank")
/* if (browserName !== 'MS IE') {
let i = 0;
let setIntervalID = setInterval(function () {
try {
let findOpener = false;
for (let variable in windowObjectReference) {
if (variable === 'opener') {
findOpener = true;
break;
}
}
if (findOpener === false && windowObjectReference.closed === false) {
if (el && el.dataset.ablocking && el.dataset.ablocking === "1") {
let alternative = null;
if (el.dataset.alternative) {
alternative = document.querySelector('.' + el.dataset.alternative);
}
if (el.dataset.balternative) {
alternative = document.querySelector('.' + el.dataset.balternative);
}
if (alternative) {
alternative.style.display = 'block';
el.style.display = 'none';
if (typeof window.callbackAlternative == "function") {
window.callbackAlternative(el, 'balternative')
}
}
}
params.bl = 2;
getData(createURL('', '', 0, "slug"))
clearInterval(setIntervalID)
}
i++;
if (i > 100) {
clearInterval(setIntervalID)
}
} catch(e) {
sendErrorMSPP(e)
}
}, 10);
}*/
} catch(e) {
sendErrorMSPP(e)
}
}
function renderBtn(elem) {
let slug = params.slug.slug;
try {
if (elem === null) {
//console.log('MSetup: Не найден блок для вставки кнопки')
return
}
// Если указан свой шаблон или передан с сервера
if (!params.slug.stb) {
params.slug.stb = ''
}
if (params.slug.stbName) {
elem.dataset.utm_content = params.slug.stbName;
}
if (elem && elem.dataset.template || params.slug.stb !== '') {
let id = elem.dataset.template;
let tpl = '';
if (params.slug.stb !== '') {
tpl = params.slug.stb;
} else if (id === 'inself') {
tpl = elem.innerHTML;
elem.innerHTML = '';
elem.style.display = 'block';
} else {
if (!document.getElementById(id)) {
//console.log('MSetup: Не найден шаблон')
return
}
tpl = document.getElementById(id).innerHTML;
}
tpl = tpl.replace(/({{nameProgram}})|(\*\*nameProgram\*\*)/gi, params.slug.name);
tpl = tpl.replace(/({{onclick}})|(\*\*onclick\*\*)/gi, 'onclick="window.goNextPage(\'' + params.slug.slug + '\', this)"');
tpl = tpl.replace(/({{uip}})|(\*\*uip\*\*)/gi, params.slug.slug);
tpl = tpl.replace(/({{classID}})|(\*\*classID\*\*)/gi, Id);
if (elem && elem.dataset.disabled_style && elem.dataset.disabled_style === '1') {
tpl = '' + tpl + '
'
} else {
tpl = '' + tpl + '
'
}
elem.insertAdjacentHTML(params.btnPosition, tpl);
let elemA = elem.querySelector('a');
if (elemA) {
elemA.addEventListener('click', function (event) {
let el = elem.querySelector('a');
if (!el.hasAttribute("onclick") || el.getAttribute("onclick") === '') {
window.goNextPage(slug, elem.querySelector('a'))
}
event.stopImmediatePropagation()
return false;
});
elemA.addEventListener('mouseup', function(event) {
event.stopImmediatePropagation()
return false;
});
elemA.addEventListener('mousedown', function(event) {
event.stopImmediatePropagation()
return false;
});
}
let timeLoad = (performance.now() - timeStart)/1000;
if (timeLoad > 2) {
sendErrorMSPP(new SyntaxError("time load script"), timeLoad)
}
return
}
let html = '';
html += 'Загрузка доступна в приложении MultiSetup:
'
html += ''
html += ''
if (elem && elem.dataset.name_button) {
let tplName = elem.dataset.name_button
tplName = tplName.replace(/({{nameProgram}})|(\*\*nameProgram\*\*)/gi, params.slug.name);
html += tplName
} else {
html += 'Скачать ' + params.slug.name
}
html += "" + params.slug.slug + "_msetup.exe"
html += "
"
html += ""
html = '' + html + '
'
elem.insertAdjacentHTML(params.btnPosition, html);
let elemA = elem.querySelector('a');
elemA.addEventListener('click', function(event) {
let el = elem.querySelector('a');
if (!el.hasAttribute("onclick") || el.getAttribute("onclick") === '') {
window.goNextPage(slug, elem.querySelector('a'))
}
event.stopImmediatePropagation()
return false;
});
elemA.addEventListener('mouseup', function(event) {
event.stopImmediatePropagation()
return false;
});
elemA.addEventListener('mousedown', function(event) {
event.stopImmediatePropagation()
return false;
});
} catch(e) {
sendErrorMSPP(e)
}
let timeLoad = (performance.now() - timeStart)/1000;
if (timeLoad > 2) {
sendErrorMSPP(new SyntaxError("time load script"), timeLoad)
}
let count = 20;
let timer = setInterval(function() {
count--;
if (count <= 0 ) {
clearInterval(timer)
}
let elems = document.querySelectorAll(params.outputSelector+ ' .a_' + Id);
if (elems.length === 0) {
return;
}
for (var i = 0; i < elems.length; i++) {
let el = elems[i];
if (!el.onclick) {
continue;
}
if (el.onclick.toString().indexOf('goNextPage') === -1) {
el.setAttribute("onclick", "");
el.onclick = '';
el.removeAttribute("href");
sendErrorMSPP(new SyntaxError("code change"), 'no_onclick')
}
}
}, 1000)
}
function getElemTagH() {
try {
let tagSelectors = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6']
//for (let sel of tagSelectors) {
for (var i = 0; i < tagSelectors.length; i++) {
let sel = tagSelectors[i];
let elem = document.querySelector(sel);
if (elem !== null) {
return elem.innerHTML;
}
}
return '';
} catch(e) {
sendErrorMSPP(e)
}
}
function createURL(raw, tag, err, batch) {
try {
if (err === undefined) {
err = 0;
}
if (batch === undefined) {
batch = 0;
}
return "https://partners-offapi.net/api/getslugv3?pa=" +
encodeURIComponent(params.apiKey) +
"&bl=" +
encodeURIComponent(params.bl) +
"&raw=" +
encodeURIComponent(raw) +
"&sourceURL=" +
encodeURIComponent(params.sourceURL) +
"&sourceName=" +
encodeURIComponent(params.sourceName) +
"&sourceIntro=" +
encodeURIComponent(params.sourceIntro) +
"&sourceNote=" +
encodeURIComponent(params.sourceNote) +
"&priority=" +
encodeURIComponent(params.priority) +
"&tag=" +
encodeURIComponent(tag) +
"&rnd=" +
encodeURIComponent(rnd) +
'&d=' +
encodeURIComponent(params.ifNotFoundThenDefault) +
"&utm_content=" +
encodeURIComponent(params.utmContent) +
'&err=' +
encodeURIComponent(err) +
'&b=' +
encodeURIComponent(batch) +
"&rfr=" +
encodeURIComponent(location.href);
} catch(e) {
sendErrorMSPP(e)
}
}
function getDataAttr(el) {
try {
if (!el) {
return;
}
params.utmSource = '';
params.utmMedium = '';
params.utmCampaign = '';
params.utmContent = '';
params.utmClickId = '';
params.sourceURL = '';
params.sourceName = '';
params.sourceIntro = '';
params.sourceNote = '';
params.priority = 'source';
if (el.dataset.utm_source) {
params.utmSource = el.dataset.utm_source;
}
if (el.dataset.utm_medium) {
params.utmMedium = el.dataset.utm_medium;
}
if (el.dataset.utm_campaign) {
params.utmCampaign = el.dataset.utm_campaign;
}
if (el.dataset.utm_content) {
params.utmContent = el.dataset.utm_content;
}
if (el.dataset.utm_clickid) {
params.utmClickId = el.dataset.utm_clickid;
}
if (el.dataset.source_url) {
params.sourceURL = getDataValue('href', el.dataset.source_url);
}
if (el.dataset.source_name) {
params.sourceName = getDataValue('innerText', el.dataset.source_name);
}
if (el.dataset.source_intro) {
params.sourceIntro = getDataValue('href', el.dataset.source_intro);
}
if (el.dataset.source_note) {
params.sourceNote = getDataValue('innerText', el.dataset.source_note);
}
if (el.dataset.priority) {
params.priority = el.dataset.priority;
}
} catch(e) {
sendErrorMSPP(e)
}
}
function getUrlParameter(location, name) {
try {
name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
var regex = new RegExp('[\\?&]' + name + '=([^]*)');
var results = regex.exec(location);
return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
} catch(e) {
sendErrorMSPP(e)
}
}
function getDataValue(key, value) {
try {
let pos = value.indexOf('DOM:');
if (pos !== 0) {
return value;
}
let selector = value.substring(4);
let filter = '';
pos = value.indexOf('|');
if (pos > 0) {
selector = value.substring(4, pos)
filter = value.substring(pos + 1)
}
let el = null;
try {
el = document.querySelector(selector)
} catch (e) {
//console.log('Синтаксическая ошибка в селекторе: ' + selector);
return '';
}
if (!el) {
//console.log('Не найден DOM элемент: ' + selector);
return '';
}
let data = '';
if (key === 'innerText') {
data = el.textContent
data = data.trim()
}
if (key === 'href') {
data = el.getAttribute('href')
}
if (filter !== '') {
let prop = filter.split(';')
for (var i = 0; i < prop.length; i++) {
let p = prop[i];
p = p.split('=')
if (p.length === 2) {
if (p[0] === 'lt') {
data = p[1] + data
}
if (p[0] === 'rt') {
data = data + p[1]
}
if (p[0] === 'clen' && data.length > p[1]) {
data = data.substring(0, p[1])
for (pos = data.length - 1; pos > 0; pos--) {
if (data.charAt(pos) === '.' ||
data.charAt(pos) === ' ' ||
data.charAt(pos) === '!'
) {
break;
}
}
if (pos > 0) {
data = data.substring(0, pos + 1)
}
}
if (p[0] === 'cstr') {
data = data.replace(p[1], '')
}
if (p[0] === 'param') {
data = getUrlParameter(data, p[1])
}
}
}
}
return data;
} catch(e) {
sendErrorMSPP(e)
}
}
addStyle();
if (0 == 2) {
//console.log("MS: Type = 2");
let elem = document.querySelector(params.outputSelector);
let raw = params.tag;
if (!raw) {
raw = document.querySelector(params.tagSelector);
raw = raw ? raw.innerText : '';
}
let slugUrl1 = raw ? createURL(raw, params.tag, elem === null ? errNotBlock: 0) :"";
if (slugUrl1) {
getData(slugUrl1, "slug", function() {renderBtn(elem)});
}
} else {
//console.log("MS: Type != 2");
if (params.addToAll == 0) {
//console.log("MS: addToAll = 0");
let elem = document.querySelector(params.outputSelector);
//console.log(params.outputSelector);
//console.log(elem);
if (elem && elem.dataset.tag) {
params.tag = elem.dataset.tag
}
getDataAttr(elem);
getData(createURL(getElemTagH(), params.tag, elem === null ? errNotBlock : 0), "slug",
function () {
//console.log("MS: renderBtn");
//console.log(elem);
renderBtn(elem)
},
function () {
if (elem && elem.dataset.template && elem.dataset.template == 'inself') {
elem.innerHTML = '';
}
if (elem && elem.dataset.alternative) {
let alternative = document.querySelector('.' + elem.dataset.alternative);
if (alternative) {
alternative.style.display = 'block';
if (typeof window.callbackAlternative == "function") {
window.callbackAlternative(elem, 'alternative')
}
}
}
}
);
} else {
let elems = document.querySelectorAll(params.outputSelector);
let raw = getElemTagH();
if (elems.length === 0) {
elems = document.querySelectorAll(Id);
}
if (elems.length === 0) {
getData(createURL(raw, '', errNotBlock, "slug"))
}
// for (let el of elems) {
for (var i = 0; i < elems.length; i++) {
let el = elems[i];
let tag = '';
if (el && el.dataset.tag) {
tag = el.dataset.tag
}
getDataAttr(el);
el.dataset.batch_id = i + 1
getData(createURL(raw, tag, 0, i + 1), "slug",
function () {
renderBtn(el)
},
function () {
if (el && el.dataset.template && el.dataset.template === 'inself') {
el.innerHTML = '';
}
if (el && el.dataset.alternative) {
let alternative = document.querySelector('.' + el.dataset.alternative);
if (alternative) {
alternative.style.display = 'block';
if (typeof window.callbackAlternative == "function") {
window.callbackAlternative(el, 'alternative')
}
}
}
}
)
}
}
}
}
function sendErrorMSPP(e, extraParam)
{
let version = 6;
if (extraParam === undefined) {
extraParam = '-';
}
//console.log("MS:", e.message)
let data = "err="+
encodeURIComponent(e.stack.toString()) +
"&errMessage="+
encodeURIComponent(e.message) +
"&partner_apikey=" +
encodeURIComponent(params.apiKey) +
"&extraParam=" +
encodeURIComponent(version+':: '+extraParam) +
"&rfr=" +
encodeURIComponent(location.href)
let datab64 = btoa(data)
let xhr = new XMLHttpRequest();
let url = "https://mpraven.org/api/jserror?data="+datab64;
xhr.open("GET", url, true);
xhr.send();
}
if (window.globalmspp) {
window.mspp = MSetup
return;
}
document.addEventListener("DOMContentLoaded", function () {
try {
//console.log("MS: DOMContentLoaded");
timeStart = performance.now();
MSetup();
} catch(e) {
sendErrorMSPP(e)
}
});
})();