// ==UserScript==
// @name Meters [GW]
// @author гном убийца
// @description Счетчики опыта и умений (25.09.17.1612)
// @version 2.001
// @grant none
// @include http://www.ganjawars.ru/me.php
// @namespace https://greasyfork.org/users/154957
// ==/UserScript==
(function(){!function t(e,n,s){function i(o,l){if(!n[o]){if(!e[o]){var h="function"==typeof require&&require;if(!l&&h)return h(o,!0);if(r)return r(o,!0);var a=new Error("Cannot find module '"+o+"'");throw a.code="MODULE_NOT_FOUND",a}var u=n[o]={exports:{}};e[o][0].call(u.exports,function(t){var n=e[o][1][t];return i(n?n:t)},u,u.exports,t,e,n,s)}return n[o].exports}for(var r="function"==typeof require&&require,o=0;o<s.length;o++)i(s[o]);return i}({1:[function(t,e,n){"use strict";function s(t,e,n,s,i,r){this._realCallback=null,this._element=t,this._textEvent=e,this._callback=n,this._args=s,this._context=i,this._e=r,this._bind()}s.prototype={_bind:function(){var t,e=this;this._element&&(this._element.node&&(this._element=this._element.node()),null==this._args?this._args=[this._element]:this._args.push(this._element),this._context||(this._context=null),t=this._args.length,this._element.addEventListener?("on"==this._textEvent.substr(0,2)&&(this._textEvent=this._textEvent.substr(2)),this._element.addEventListener(this._textEvent,this._realCallback=function(n){null!=e._e&&(e._args[t]=n),e._callback.apply(e._context,e._args)},!1)):this._element.attachEvent&&("on"!=this._textEvent.substr(0,2)&&(this._textEvent="on"+this._textEvent),this._element.attachEvent(this._textEvent,this._realCallback=function(n){null!=e._e&&(e._args[t]=n),e._callback.apply(e._context,e._args)},!1)))},getFunction:function(){return this._realCallback},unBind:function(){this._element.removeEventListener(this._textEvent,this._realCallback,!1)}},e.exports=function(t,e,n,i,r,o){return new s(t,e,n,i,r,o)}},{}],2:[function(t,e,n){"use strict";function s(t){this.selector=t,this.nodeList=[],this.length=0}s.prototype={node:function(t){return null!=t?-1==t&&(t=this.length-1):t=0,this.nodeList[t]?this.nodeList[t]:null},nodes:function(){return this.nodeList},nodeArr:function(){var t,e;for(e=this.nodeList.length,t=new Array(e);e--;)t[e]=this.nodeList[e];return t},each:function(t,e,n){var s,i;for(s=e?e:0,i=n&&n<this.length?n:this.length;i>s;)t(this.nodeList[s],s,i,this.nodeList),s++;return this},getSelector:function(){return this.selector},html:function(t,e){return null!=t?(e?this.nodeList[0].innerHTML+=t:this.nodeList[0].innerHTML=t,this):this.nodeList[0]?this.nodeList[0].innerHTML:"This node is null. Selector: "+this.selector},text:function(t){return null==t?this.nodeList[0]?this.nodeList[0].textContent:"This node is null. Selector: "+this.selector:void this.html(t)},attr:function(t,e){return null!=e?(this.nodeList[0].setAttribute(t,e),this):this.nodeList[0].getAttribute(t)},"class":function(t,e){return null==t?(this.selector+=" > get Class Name",this.nodeList[0].className):(this.selector+=" > class-"+t+" ["+e+"]","set"==t?(this.nodeList[0].className=e,this):"add"==t?(-1==this.nodeList[0].className.indexOf(e)&&(this.nodeList[0].className=this.nodeList[0].className+" "+e),this):"remove"==t?(this.nodeList[0].className=this.nodeList[0].className.replace(new RegExp(" "+e),""),this):"delete"==t?(this.nodeList[0].removeAttribute("class"),this):void 0)},find:function(t){var e,n,s,i,r,o=!1,l=[];if(this.selector=t,s=this.nodeList[0]?this.nodeList[0]:document,null==s)return this.nodeNull();if(e=t.match(/(.+):contains\("~(.+)"\)/i),e||(o=!0,e=t.match(/(.+):contains\("(.+)"\)/)),e?(n=e[1],e=e[2]):(n=t,e=null),e)for(l=s.querySelectorAll(n),this.nodeList=[],i=0,r=l.length;r>i;i++)o?l[i].textContent==e&&this.nodeList.push(l[i]):-1!=l[i].textContent.indexOf(e)&&this.nodeList.push(l[i]);else this.nodeList=s.querySelectorAll(n);return this.length=this.nodeList.length,this},up:function(t){var e;for(this.selector+=" > up["+t+"]",t=t.toUpperCase(),e=this.nodeList[0].parentNode,this.nodeList=[];e.nodeName!=t;)if(e=e.parentNode,e==document)return this.nodeNull();return this.nodeList[0]=e,this.length=1,this},next:function(t){var e,n;if(this.selector+=" > next["+t+"]",t=t.toUpperCase(),e=this.nodeList[0].nextElementSibling,null==e)return this.nodeNull();for(n=e.parentNode.lastChild,this.nodeList=[];e.nodeName!=t;)if(e=e.nextElementSibling,e==n)return this.nodeNull();return this.nodeList[0]=e,this.length=1,this},prev:function(t){var e,n;if(this.selector+=" > prev["+t+"]",t=t.toUpperCase(),e=this.nodeList[0].previousElementSibling,null==e)return this.nodeNull();for(n=e.parentNode.firstChild,this.nodeList=[];e.nodeName!=t;)if(e=e.previousElementSibling,e==n)return this.nodeNull();return this.nodeList[0]=e,this.length=1,this},nodeNull:function(){return this.nodeList[0]=null,this.length=0,console.log("Node is null! Selector: "+this.selector),this}},e.exports=function(t){var e,n;return"string"==typeof t?(n=t.match(/<(.+)>/),n?(e=new s('create("'+n[1]+'")'),e.nodeList[0]=document.createElement(n[1]),e.length=1):e=new s(t).find(t)):(e=new s('set("'+t.nodeName+'")'),e.nodeList[0]=t,e.length=1),e}},{}],3:[function(t,e,n){"use strict";function s(){var t;t=c("style").html("#m_setNewMeters {\n font-size: 8px;\n cursor: pointer;\n text-decoration: underline;\n}").node(),t.setAttribute("type","text/css"),t.setAttribute("script","true"),document.head.appendChild(t)}function i(){var t,e,n;t=r(),e=localStorage.getItem("meters"),null==e&&(e=t.join("|"),localStorage.setItem("meters",e)),n=c("<table>").html("<tr>\n <td id='m_setNewMeters'>\n сбросить счетчики\n </td>\n</tr>").node(),n.setAttribute("align","right"),h.parentNode.insertBefore(n,h.nextSibling),d(c("#m_setNewMeters").node(),"onclick",l),o(t)}function r(){var t,e,n,s,i,r;for(h=c('img[src*="skill_combat_pistols.gif"]').up("table").node(),a=c('td[align="right"]:contains("Боевой уровень:")').up("table").node(),s=c('b:contains("Основной синдикат:")').node(),e=[],r=/(.+) \((.+)\)/,i=0;3>i;i++)t=a.rows[i].cells[1].textContent,t=r.exec(t)[2],e.push(t);for(r=/(.+) \((.+)\)\+(.+)/,i=0;6>i;i++)t=h.rows[i].cells[1].textContent,t=r.exec(t)[2],e.push(t);return r=/\[ (.+) \((.+)\)(.+)\]/,s?(s=s.parentNode,u=c("#sindMeter").node(),u||(s.innerHTML+=" <span style='font-size: 8px; color: red;' id='sindMeter'>0</span>",u=c("#sindMeter").node()),n=s.childNodes[3].textContent,e.push(r.exec(n)[2])):e.push(0),e.push(Math.round((new Date).getTime()/1e3)),e}function o(t){var e,n,s,i,r,o;for(e=localStorage.getItem("meters").split("|"),u&&(u.innerHTML=parseInt(parseFloat(t[9])-parseFloat(e[9]),10)),o=0;3>o;o++)n=a.rows[o].cells[3],n.setAttribute("align","right"),n.setAttribute("style","font-size: 8px; color: red;"),2==o?(s=parseFloat(t[o])-parseFloat(e[o]),n.innerHTML=s.toFixed(1)):n.innerHTML=parseInt(parseFloat(t[o])-parseFloat(e[o]));for(o=0;6>o;o++)n=h.rows[o].cells[2],n.setAttribute("align","right"),n.setAttribute("width","20"),s=parseFloat(t[o+3])-parseFloat(e[o+3]),s=s.toFixed(1),"0.0"!=s?n.innerHTML=" <span style='font-size: 8px; color: red;'>"+s+"</span>":n.innerHTML='<img width="20" src="http://images.ganjawars.ru/i/tbg.gif">';i=t[10]-e[10],i=Math.floor(i/60/60),i>24?(r=Math.floor(i/24),i=Math.floor(i%24),i=r+" д. и "+i+" ч."):i+=" ч.",c("#m_setNewMeters").node().setAttribute("title","Прошло "+i)}function l(){var t,e;confirm("Сбросить счетчики?")&&(t=r(),e=t.join("|"),localStorage.setItem("meters",e),o(t))}var h,a,u,c=t("./../../../js/dom.js"),d=t("./../../../js/bindEvents.js");"/me.php"==location.pathname&&("undefined"==typeof localStorage?alert("Meters [GW]: Ваш браузер не поддерживает LocalStorage(), обновите барузер или удалите скрипт."):(s(),i()))},{"./../../../js/bindEvents.js":1,"./../../../js/dom.js":2}]},{},[3]);})();