// ==UserScript==
// @name Kolobok Alternative Decoder
// @namespace http://tampermonkey.net/
// @version 0.1
// @description View Kolobok parameters on simplemarket
// @author Nobody
// @match https://wax.simplemarket.io/*
// @icon https://www.google.com/s2/favicons?domain=simplemarket.io
// @require https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js
// @require https://gist.github.com/raw/2625891/waitForKeyElements.js
// @grant GM_addStyle
// @grant GM.getValue
// ==/UserScript==
//- The @grant directives are needed to restore the proper sandbox.
waitForKeyElements ("img[src*='kolobok']", loadHandling);
//waitForKeyElements ("img.mat-card-image.ng-lazyloaded[src*='kolobok']", loadHandling);
//waitForKeyElements ("img.ng-lazyloaded[src*='kolobok']", loadHandling);
function loadHandling (jNode) {
if (jNode[0].complete) {
handleImgTag (jNode);
}
else {
jNode.on ('load', handleImgTag);
}
}
function handleImgTag (jNodeOrEvent) {
var newImg;// will be jQuery node
if (jNodeOrEvent instanceof jQuery) {
newImg = jNodeOrEvent;
}
else {
newImg = $(jNodeOrEvent.target);
}
console.log ("Found new image with width ", newImg.width () );
let hashString = newImg.attr('src').split("/").slice(-1).join("/").split(".").slice(0,-1).join(".");
let kolobok = calc(hashString);
let speed_text = kolobok[0] > 100 ? ""+kolobok[0]+"" : kolobok[0];
let stealth_text = kolobok[1] > 0.5 ? ""+kolobok[1]+"" : kolobok[1];
newImg.parent().parent().append("SPEED: ",speed_text," STEALTH: ",stealth_text);
}
function calc(url) {
var e = url;
console.log(e)
const t = e.length;
const n = e.length / 2;
const l = [e.slice(0, 2), e.slice(t - 2, t)];
const r = [e.slice(n - 2, n), e.slice(n, n + 2)];
var speed = Math.abs(parseInt(l[0], 16) - parseInt(l[1], 16));
var stealth = ((255 - Math.abs(parseInt(r[0], 16) - parseInt(r[1], 16))) / 255).toFixed(2);
// console.log('stealth, speed =',stealth,', ',speed);
// let genome_info = 'Genome '+ e
// let speed_stealth = 'STEALTH: ' + stealth + ' SPEED: ' + speed
// let message = genome_info + ' ' + speed_stealth
return [speed, stealth]
// return message
}