Advertisement
Guest User

Untitled

a guest
Nov 17th, 2018
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Плагин для программы MobileBalance: http://mtsoft.ru/mobilebalance/
  2. //
  3. // Инструкция по использованию:
  4. // 1. зайти в настройки программы MobileBalance, перейти на закладку "Плагины: Операторы", добавить плагин.
  5. // 2. После этого перейти на закладку "Телефоны" и в качестве оператора выбрать оператора с названием, указанным ниже.
  6. //
  7. // FullName  : LIFE Unlim Date
  8. // ShortName : LifeByUnlimDate
  9. // Version   : 17.11.2018
  10. // Icon      : 789C73F2FDC600016540AC01C40250CCC8C002166F0062616E08166040060D10C9860608058240C6810307803448E43F1831FCFF0FA140102404E2E3007FCE43089CF49933E7A1FC337869A83A5C00009F949135
  11. // Author    : Artem Brodetsky
  12. // Types     : Artem Brodetsky
  13. // Descript  : Текущий счет в системе статистики провайдера LIFE респ. Беларусь
  14. // Descript  : Адрес личного кабинета: https://issa.life.com.by/Account.aspx
  15.  
  16. var JSON;JSON||(JSON={});
  17. (function(){function k(a){return a<10?"0"+a:a}function o(a){p.lastIndex=0;return p.test(a)?'"'+a.replace(p,function(a){var c=r[a];return typeof c==="string"?c:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+a+'"'}function l(a,j){var c,d,h,m,g=e,f,b=j[a];b&&typeof b==="object"&&typeof b.toJSON==="function"&&(b=b.toJSON(a));typeof i==="function"&&(b=i.call(j,a,b));switch(typeof b){case "string":return o(b);case "number":return isFinite(b)?String(b):"null";case "boolean":case "null":return String(b);case "object":if(!b)return"null";
  18. e+=n;f=[];if(Object.prototype.toString.apply(b)==="[object Array]"){m=b.length;for(c=0;c<m;c+=1)f[c]=l(c,b)||"null";h=f.length===0?"[]":e?"[\n"+e+f.join(",\n"+e)+"\n"+g+"]":"["+f.join(",")+"]";e=g;return h}if(i&&typeof i==="object"){m=i.length;for(c=0;c<m;c+=1)typeof i[c]==="string"&&(d=i[c],(h=l(d,b))&&f.push(o(d)+(e?": ":":")+h))}else for(d in b)Object.prototype.hasOwnProperty.call(b,d)&&(h=l(d,b))&&f.push(o(d)+(e?": ":":")+h);h=f.length===0?"{}":e?"{\n"+e+f.join(",\n"+e)+"\n"+g+"}":"{"+f.join(",")+
  19. "}";e=g;return h}}if(typeof Date.prototype.toJSON!=="function")Date.prototype.toJSON=function(){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+k(this.getUTCMonth()+1)+"-"+k(this.getUTCDate())+"T"+k(this.getUTCHours())+":"+k(this.getUTCMinutes())+":"+k(this.getUTCSeconds())+"Z":null},String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(){return this.valueOf()};var q=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
  20. p=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,e,n,r={"\u0008":"\\b","\t":"\\t","\n":"\\n","\u000c":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},i;if(typeof JSON.stringify!=="function")JSON.stringify=function(a,j,c){var d;n=e="";if(typeof c==="number")for(d=0;d<c;d+=1)n+=" ";else typeof c==="string"&&(n=c);if((i=j)&&typeof j!=="function"&&(typeof j!=="object"||typeof j.length!=="number"))throw Error("JSON.stringify");return l("",
  21. {"":a})};if(typeof JSON.parse!=="function")JSON.parse=function(a,e){function c(a,d){var g,f,b=a[d];if(b&&typeof b==="object")for(g in b)Object.prototype.hasOwnProperty.call(b,g)&&(f=c(b,g),f!==void 0?b[g]=f:delete b[g]);return e.call(a,d,b)}var d,a=String(a);q.lastIndex=0;q.test(a)&&(a=a.replace(q,function(a){return"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)}));if(/^[\],:{}\s]*$/.test(a.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,
  22. "]").replace(/(?:^|:|,)(?:\s*\[)+/g,"")))return d=eval("("+a+")"),typeof e==="function"?c({"":d},""):d;throw new SyntaxError("JSON.parse");}})();
  23.  
  24. if (typeof Array.prototype.forEach != 'function') {
  25.     Array.prototype.forEach = function(callback){
  26.       for (var i = 0; i < this.length; i++){
  27.         callback.apply(this, [this[i], i, this]);
  28.       }
  29.     };
  30. }
  31.  
  32. function main(){
  33.     var p = 0;
  34.     // Делаем логаут
  35.     document.location="https://life.com.by/~api/json/extend.otp/logout";
  36.     if(!external.WaitBrowser) return;
  37.     response.pages[p++]=external.source;
  38.  
  39.     loginPackage = {
  40.      "msisdn" : '375'+request.loginValue,
  41.      "password" :  request.passwValue
  42.     }
  43.    
  44.     xmlhttp = external.getXmlHttp()
  45.     xmlhttp.open('POST', 'https://life.com.by/~api/json/extend.lifeconnector/getOauthAccessToken', false);
  46.     xmlhttp.setRequestHeader("Content-Type","application/json;charset=UTF-8");
  47.     xmlhttp.send(JSON.stringify(loginPackage));
  48.     if(xmlhttp.status != 200) return
  49.     loginObj = JSON.parse(xmlhttp.responseText);
  50.  
  51.     balancePackage = {
  52.         chainName: "LHA_getUserBalance",
  53.         language: "rus"
  54.     }
  55.  
  56.     xmlhttp.open('POST', 'https://life.com.by/~api/json/extend.account/getAccountData', false);
  57.     xmlhttp.setRequestHeader("Content-Type","application/json;charset=UTF-8");
  58.     xmlhttp.send(JSON.stringify(balancePackage));
  59.     if(xmlhttp.status != 200) return
  60.     balanceObj = JSON.parse(xmlhttp.responseText);
  61.  
  62.    
  63.     tariffPackage = {
  64.         chainName: "LH_Active_TP",
  65.         language: "rus"
  66.     }
  67.    
  68.     xmlhttp.open('POST', 'https://life.com.by/~api/json/extend.account/getAccountData', false);
  69.     xmlhttp.setRequestHeader("Content-Type","application/json;charset=UTF-8");
  70.     xmlhttp.send(JSON.stringify(tariffPackage));
  71.     if(xmlhttp.status != 200) return
  72.     tariffObj = JSON.parse(xmlhttp.responseText);
  73.  
  74.  
  75.  
  76.     counterPackage = {
  77.         chainName: "LHA_getCurrentBalances",
  78.         language: "rus"
  79.     }
  80.    
  81.     xmlhttp.open('POST', 'https://life.com.by/~api/json/extend.account/getAccountData', false);
  82.     xmlhttp.setRequestHeader("Content-Type","application/json;charset=UTF-8");
  83.     xmlhttp.send(JSON.stringify(counterPackage));
  84.     if(xmlhttp.status != 200) return
  85.     counterObj = JSON.parse(xmlhttp.responseText);
  86.     external.SaveStrToLogFile(xmlhttp.responseText);
  87.    
  88.     response.Balance = parseFloat(loginObj.userData.balance)
  89.  
  90.     minLife = '?'
  91.     minAllNets = '?'
  92.     mb = '?'
  93.     mbSocNet = '?'
  94.     smsLife = '?'
  95.     smsAllNets = '?'
  96.     counterObj.forEach(function(item,i,arr){
  97.     switch (item.emptyIconType) {
  98.      case 'traffic':
  99.         mb = item.title.replace('МБ.','').replace(' ','')
  100.         mbSocNet = item.text.replace('МБ.','').replace(' ','')
  101.         break
  102.      case 'call':
  103.         minAllNets = item.title.replace('мин.','').replace(' ','')
  104.         minLife = item.text.replace('мин.','').replace(' ','')
  105.         break
  106.      case 'sms':
  107.         smsAllNets = item.title.replace('SMS','').replace(' ','')
  108.         smsLife = item.text.replace('SMS','').replace(' ','')
  109.         break
  110.     }
  111.  
  112.     if (mb == "") mb = '0'
  113.     if (mbSocNet == "") mbSocNet = '0'
  114.     if (minAllNets == "") minAllNets = '0'
  115.     if (minLife == "") minLife = '0'
  116.     if (smsAllNets == "") smsAllNets = '0'
  117.     if (smsLife == "") smsLife = '0'
  118.  
  119.     response.UserName = ('M:'+minAllNets+'/'+minLife+
  120.                        ' I:'+mb+'/'+mbSocNet+
  121.                        ' S:'+smsLife+'/'+smsAllNets+
  122.                        ' '+tariffObj.next_trigger).replace('M:0/0','').replace('I:0/0','').replace('S:0/0','').replace(/Безлимит/g,'U').replace(new RegExp('  ', 'g'),' ').replace(new RegExp('U/U', 'g'),'U')
  123.     });
  124.    
  125.    
  126.  
  127. };
  128. main();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement