NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript==
// @name PA console
// @namespace analytics.prostoy.ru
// @version 0.1
// @license MIT
// @description console for PA
// @author Salyga Yaroslav
// @grant none
// @match *://*/*
// ==/UserScript==
(function() {
'use strict';
function getCookie(name) {
let matches = document.cookie.match(new RegExp(
"(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)"
));
return matches ? decodeURIComponent(matches[1]) : undefined;
}
window.pa_tampermonkey_debug = true;
let body = window.document.body;
body.innerHTML += '<div id="consolePa" style="padding: 10px; position: fixed;top: 0;right: 0;width:400px;height: 300px;background-color: rgba(255,255,255,.5);z-index: 10000;overflow-y: auto;border: 1px solid #ccc;overflow-x: hidden;word-break: break-all;"></div>';
let consol = window.document.getElementById('consolePa');
document.addEventListener('tampermonkey.debug.init.counter', function (data) {
let json = JSON.parse(data.detail.data);
consol.innerText += 'Запуск счетчика...\n\n';
consol.innerText += 'Проект: '+data.detail.site+'\n';
consol.innerText += 'Клиент:\n'+json.client_id+'\n';
consol.scrollTop = consol.scrollHeight;
}, true)
document.addEventListener('tampermonkey.debug.presend.counter', function (data) {
let json = data.detail.data;
consol.innerText += '\nОтправка данных для визита:\n';
consol.innerText += json+'\n';
consol.scrollTop = consol.scrollHeight;
}, true)
document.addEventListener('tampermonkey.debug.result.counter', function (data) {
let json = data.detail.data;
console.log(json);
consol.innerText += '\nПолученные данные:\n\n';
consol.innerText += 'Визит: '+json.id+'\n';
consol.innerText += 'Страна: '+json.country+'\n';
consol.innerText += 'Город: '+json.city+'\n';
consol.innerText += 'Код страны: '+json.countryCode+'\n';
consol.scrollTop = consol.scrollHeight;
}, true)
})();