hwm_exp_ability

Высчитывание экспоумки для взятия ап умки на своем уровне

当前为 2015-12-01 提交的版本,查看 最新版本

  1. //
  2. // ==UserScript==
  3. // @name hwm_exp_ability
  4. // @author Pahan https://gf.qytechs.cn/uk/users/18377-pahan
  5. // @namespace hwm_pahan
  6. // @description Высчитывание экспоумки для взятия ап умки на своем уровне
  7. // @homepage https://gf.qytechs.cn/uk/scripts/13724-hwm-exp-ability
  8. // @icon http://dcdn.heroeswm.ru/avatars/30/nc-5/30547.gif
  9. // @version 1.15
  10. // @encoding utf-8
  11. // @include http://*.heroeswm.ru/home.php*
  12. // @include http://*heroeswm.ru/transfer.php*
  13. // @include http://*lordswm.com/home.php*
  14. // @include http://*lordswm.com/transfer.php*
  15. // @include http://178.248.235.15/home.php*
  16. // @include http://178.248.235.15/transfer.php*
  17. // @grant GM_deleteValue
  18. // @grant GM_getValue
  19. // @grant GM_listValues
  20. // @grant GM_setValue
  21. // @grant GM_addStyle
  22. // @grant GM_log
  23. // @grant GM_openInTab
  24. // @grant GM_xmlhttpRequest
  25. // ==/UserScript==
  26.  
  27. var version = '1.15';
  28. var idn = 'exp_ability';
  29. var str_url = 'https://gf.qytechs.cn/uk/scripts/13724-hwm-exp-ability';
  30. var str_script_name = 'Експоумка';
  31. var str_url_aut = '/sms-create.php?mailto=Pahan&subject=Скрипт: '+str_script_name+' v'+version+'. Найдена ошибка:';
  32. var str_url_sps = '/transfer.php?pahan_sps=' + encodeURIComponent('Подарок. Спасибо за скрипт: '+str_script_name+' v'+version+'.');
  33.  
  34. if (typeof GM_deleteValue != 'function') {
  35. this.GM_getValue=function (key,def) {return localStorage[key] || def;};
  36. this.GM_setValue=function (key,value) {return localStorage[key]=value;};
  37. this.GM_deleteValue=function (key) {return delete localStorage[key];};
  38.  
  39. this.GM_addStyle=function (key) {
  40. var style = document.createElement('style');
  41. style.textContent = key;
  42. document.querySelector("head").appendChild(style);
  43. }
  44. }
  45. if (typeof GM_listValues != 'function') {
  46. this.GM_listValues=function () {
  47. var values = [];
  48. for (var i=0; i<localStorage.length; i++) {
  49. values.push(localStorage.key(i));
  50. }
  51. return values;
  52. }
  53. }
  54.  
  55. GM_addStyle('.dialog {background-color: #F6F3EA; border-radius: 5px; box-sizing: border-box; box-shadow: 0 0 0px 12px rgba(200, 200, 200, 0.5); left: calc(50% - 300px); max-height: calc(100% - 100px); overflow: auto; padding: 15px; position: fixed; top: 50px; z-index: 1105;}');
  56. GM_addStyle('.dialogOverlay {background-color: rgba(0, 0, 0, 0.7); height: 100%; left: 0; position: fixed; top: 0; width: 100%;}');
  57. GM_addStyle('.btn_close {position:absolute;left:calc(100% - 45px);float:right;border:1px solid #abc;width:15px;height:15px;text-align:center;cursor:pointer;}');
  58. GM_addStyle('.btn_settings {text-decoration:underline;cursor:pointer;font-weight:bold;font-size:10px;width:500px;}');
  59. GM_addStyle('.small_text {font-weight:bold;font-size:10px;}');
  60.  
  61. function addEvent(elem, evType, fn) {
  62. // elem["on" + evType] = fn;
  63. if (elem.addEventListener) {
  64. elem.addEventListener(evType, fn, false);
  65. }
  66. else if (elem.attachEvent) {
  67. elem.attachEvent("on" + evType, fn);
  68. }
  69. else {
  70. elem["on" + evType] = fn;
  71. }
  72. }
  73.  
  74. function $(id) { return document.querySelector(id); }
  75.  
  76. function URLAttrValueGet(attr_name, aurl)
  77. {
  78. attr_name = attr_name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  79. var regexS = "[\\?&]" + attr_name + "=([^&#]*)";
  80. var regex = new RegExp( regexS );
  81. var results = regex.exec( aurl );
  82. if( results == null )
  83. return "";
  84. else
  85. return results[1];
  86. }
  87.  
  88. function Ajax(AMethod, AURL, AParams, ACallBackFunc)
  89. {
  90. var LRequest = new XMLHttpRequest();
  91. LRequest.open(AMethod, AURL, true);
  92. LRequest.overrideMimeType('text/html; charset=windows-1251');
  93. LRequest.send(AParams);
  94. LRequest.onreadystatechange = function()
  95. {
  96. if (LRequest.readyState == 4)
  97. {
  98. ACallBackFunc(LRequest.responseText);
  99. }
  100. };
  101. }
  102.  
  103. function Trim(AText)
  104. {
  105. return AText.replace(/^\s+|\s+$|^(&nbsp;)+|(&nbsp;)+$/g, '');
  106. }
  107.  
  108. function DeleteCRLF(AText)
  109. {
  110. return AText.replace(/[\n\r]/g, ' ').replace(/\s{2,}/g, ' ');
  111. }
  112.  
  113. function Assert(ACondition, AMessage)
  114. {
  115. if (ACondition)
  116. return;
  117. localStorage['trade.status'] = 'Stoped';
  118. alert('ERROR: ' + AMessage);
  119. throw new Error(AMessage);
  120. }
  121.  
  122. function FloatFormat(AFloat)
  123. {
  124. return Math.round(AFloat).toString();
  125. }
  126.  
  127. function IntFormatWithThouthandSeparator(num){
  128. var n = num.toString(), p = n.indexOf('.');
  129. return n.replace(/\d(?=(?:\d{3})+(?:\.|$))/g, function($0, i){
  130. return p<0 || i<p ? ($0+',') : $0;
  131. });
  132. }
  133.  
  134. // ------------------ settings
  135.  
  136. function close_setting_form() {
  137. bg = $('#bgOverlay' + idn) ;
  138. bgc = $('#bgCenter' + idn) ;
  139. if( bg ) {
  140. bg.style.display = bgc.style.display = 'none' ;
  141. }
  142. }
  143.  
  144. function clear_all_params()
  145. {
  146. if (confirm("Вы действительно хотите скинуть все сохраненные настройки?"))
  147. {
  148. var keys = GM_listValues();
  149. for (var i=0, key=null; key=keys[i]; i++) {
  150. GM_deleteValue(key);
  151. }
  152. close_find_work_info();
  153. }
  154. }
  155.  
  156. function setCheck(ch)
  157. {
  158. if( GM_getValue( ch ) && GM_getValue( ch ) == 1 )
  159. GM_setValue( ch , 0 );
  160. else
  161. GM_setValue( ch , 1 );
  162. }
  163.  
  164. function setEdit(id, key)
  165. {
  166. var LValue = parseInt($('#' + id).value);
  167. GM_setValue(key, LValue);
  168. }
  169.  
  170. function show_settings_base(AShowSettingsHeder, ASettingsHTML)
  171. {
  172. bg = $('#bgOverlay' + idn) ;
  173. bgc = $('#bgCenter' + idn) ;
  174. if( !bg ) {
  175. bg = document.createElement('div') ;
  176. bg.id = 'bgOverlay' + idn;
  177. document.body.appendChild( bg );
  178. bg.className = 'dialogOverlay';
  179. addEvent(bg, 'click', close_setting_form);
  180.  
  181. bgc = document.createElement('div') ;
  182. bgc.id = 'bgCenter' + idn ;
  183. document.body.appendChild( bgc );
  184. bgc.className = 'dialog';
  185. }
  186. bg.style.display = bgc.style.display = 'block' ;
  187.  
  188. var LSettingsHeader = AShowSettingsHeder ? '<tr><td><b>Настройки:</b></td></tr>' : '';
  189. bgc.innerHTML =
  190. '<div style="border:1px solid #abc;padding:5px;margin:2px;">' +
  191. ' <div class="btn_close" id="bt_close'+idn+'" title="Закрыть">x</div>' +
  192. ' <center>' +
  193. ' <table>' +
  194. ' <tr>' +
  195. ' <td><b>'+str_script_name+' <font style="color:#0070FF;">'+version+'</font></b></td>' +
  196. ' </tr>' +
  197. ' <tr><td><hr/></td></tr>' +
  198. ' ' + LSettingsHeader +
  199. ' <tr>' +
  200. ' <td>' + ASettingsHTML + '</td>' +
  201. ' </tr>' +
  202. ' <tr><td><hr/></td></tr>' +
  203. ' <tr>' +
  204. ' <td class="small_text" >' +
  205. ' <a class="small_text" href="'+str_url+'">Обновить</a>&nbsp;&nbsp;' +
  206. ' <a class="small_text" href="'+str_url_aut+'">Нашли ошибку?</a>&nbsp;&nbsp;' +
  207. ' <a class="small_text" href="'+str_url_sps+'">Сказать спасибо</a>&nbsp;&nbsp;' +
  208. ' <a class="small_text" style="left:calc(50% - 100px);" href="javascript:void(0);" id="settings_reset'+idn+'">Скинуть все настройки</a> ' +
  209. ' </td>' +
  210. ' </tr>' +
  211. ' <tr>' +
  212. ' <td class="small_text" >' +
  213. ' Автор: <a class="small_text" href="http://www.heroeswm.ru/pl_info.php?id=30547">Pahan.</a>' +
  214. ' </td>' +
  215. ' </tr>' +
  216. ' </table>' +
  217. ' </center>' +
  218. '</div>';
  219.  
  220. addEvent($('#bt_close' + idn), 'click', close_setting_form);
  221. addEvent($('#settings_reset' + idn), 'click', clear_all_params);
  222. }
  223.  
  224. // ------------------ settings
  225.  
  226. function SpsProcess()
  227. {
  228. if (location.href.indexOf('/transfer.php') > -1)
  229. {
  230. var LSps = decodeURIComponent(URLAttrValueGet('pahan_sps', location.href));
  231. if (LSps != '')
  232. {
  233. document.forms.f.nick.value = 'Pahan';
  234. document.forms.f.gold.value = '500';
  235. document.forms.f.desc.value = LSps;
  236. }
  237. }
  238. }
  239. SpsProcess();
  240.  
  241. //-----------------------------------
  242.  
  243. var expelem;
  244.  
  245. function GetExp()
  246. {
  247. res = -1;
  248.  
  249. var list = document.getElementsByTagName("b");
  250. for(var i = 0; i < list.length; i++)
  251. {
  252. var elem = list[i];
  253. if (elem.innerHTML.indexOf('\u0411\u043E\u0435\u0432\u043E\u0439\u0020\u0443\u0440\u043E\u0432\u0435\u043D\u044C') === 0)
  254. {
  255. var subindex = Array.prototype.indexOf.call(elem.parentNode.childNodes, elem);
  256. expelem = elem.parentNode.childNodes[subindex + 2];
  257. res = parseInt(expelem.innerHTML.replace(/,/g, ''));
  258. break;
  259. }
  260. }
  261. return res;
  262. }
  263.  
  264. function GetCurrentFractAbility(AElem)
  265. {
  266. var sublist = AElem.getElementsByTagName("b");
  267. if (sublist.length > 0)
  268. {
  269. var subitem = sublist[0];
  270. var subindex = Array.prototype.indexOf.call(subitem.parentNode.childNodes, subitem);
  271. var regex = /\((\d+.\d+)\)/;
  272. var regex_res = regex.exec(subitem.parentNode.childNodes[subindex + 1].textContent);
  273. if (regex_res)
  274. {
  275. var LAbility = parseFloat(regex_res[1]);
  276. var LAbilityToUp = parseFloat(subitem.parentNode.childNodes[subindex + 2].innerHTML);
  277. var LArray = subitem.parentNode.childNodes[subindex].innerHTML.split(': ');
  278. var LFration = LArray[0];
  279. var LAbilityLevel = parseInt(LArray[1]);
  280. return {Ability: LAbility, AbilityToUp: LAbilityToUp, Fraction: LFration,
  281. AbilityLevel: LAbilityLevel, IsCurrent: true, IsMain: false};
  282. }
  283. }
  284. }
  285.  
  286. function GetAllFractions()
  287. {
  288. var LTD = GetTD();
  289. var LResult = new Array(GetCurrentFractAbility(LTD));
  290. var LMaxAbl = LResult[0];
  291. for(i = 0; i < LTD.childNodes.length; i++)
  292. {
  293. var cur_el = LTD.childNodes[i];
  294. var html = Trim(cur_el.textContent);
  295. var regex = /\: \d+ \((\d+.\d+)\)/;
  296. var regex_res = regex.exec(html);
  297. if(regex_res)
  298. {
  299. cur_abil = parseFloat(regex_res[1]);
  300. if (html.indexOf('\u0413\u0438\u043B\u044C\u0434\u0438\u044F') === -1)
  301. {
  302. var next_el = cur_el.parentNode.childNodes[i + 1];
  303. if (next_el.tagName == 'FONT')
  304. {
  305. var LAbility = cur_abil;
  306. var LAbilityToUp = parseFloat(next_el.innerHTML);
  307. var LArray = Trim(next_el.previousSibling.textContent).split(': ');
  308. var LFration = LArray[0];
  309. var LAbilityLevel = parseInt(LArray[1].split(' (')[0]);
  310. var LNew = {Ability: LAbility, AbilityToUp: LAbilityToUp, Fraction: LFration,
  311. AbilityLevel: LAbilityLevel, IsCurrent: false, IsMain: false};
  312. LResult.push(LNew);
  313. if (LMaxAbl.Ability < LNew.Ability)
  314. LMaxAbl = LNew;
  315. }
  316. }
  317. }
  318. }
  319. LMaxAbl.IsMain = true;
  320.  
  321. return LResult;
  322. }
  323.  
  324. function GetTD()
  325. {
  326. var list = document.getElementsByTagName("td");
  327. for(var i = 0; i < list.length; i++)
  328. {
  329. var elem = list[i];
  330. // alert(elem.innerHTML);
  331. if( (Trim(elem.innerHTML).indexOf('\u0420\u044B\u0446\u0430\u0440\u044C\u003A') === 0)
  332. || (Trim(elem.innerHTML).indexOf('<b>\u0420\u044B\u0446\u0430\u0440\u044C\u003A') === 0)
  333. )
  334. {
  335. return elem;
  336. }
  337. }
  338. }
  339.  
  340. function GetAbilityToUpInfo()
  341. {
  342. var racial_skill_lvl = [20,50,90,160,280,500,900,1600,2900,5300,9600,17300];
  343. var LFract = GetFraction(GM_getValue('selected_fract', ''), GetAllFractions());
  344. var LLevel = Math.max(parseInt(GM_getValue('selected_level', 0)), (LFract.AbilityLevel + 1));
  345. var LResult = {Fraction: LFract.Fraction, Level: LLevel, AbilityToUp: -1, IsMax: false};
  346. LResult.IsMax = (LFract.AbilityLevel == racial_skill_lvl.length);
  347. if (!LResult.IsMax)
  348. LResult.AbilityToUp = racial_skill_lvl[LLevel - 1] - LFract.Ability;
  349. return LResult;
  350. }
  351.  
  352. function abil_fractions_changed()
  353. {
  354. GM_setValue('selected_fract', $("#hwm_exp_abil_fractions").value);
  355. GM_deleteValue('selected_level');
  356. UpdateAbilLevels();
  357. }
  358.  
  359. function GetFraction(AName, AAllFractions)
  360. {
  361. for(i = 0; i < AAllFractions.length; i++)
  362. {
  363. var LFract = AAllFractions[i];
  364. if ((AName == '') && LFract.IsMain || (AName != '') && (LFract.Fraction == AName))
  365. return LFract;
  366. }
  367. return AAllFractions[0];
  368. }
  369.  
  370. function UpdateAbilLevels()
  371. {
  372. var LSelect = $("#hwm_exp_abil_levels");
  373. LSelect.innerHTML = '';
  374.  
  375. var LFract = GetFraction($("#hwm_exp_abil_fractions").value, GetAllFractions());
  376. var LSelectedLevel = parseInt(GM_getValue('selected_level', 0));
  377. for(i = LFract.AbilityLevel + 1; i <= 12; i++)
  378. {
  379. var option = document.createElement("option");
  380. option.value = i;
  381. option.text = i;
  382. if (i == LSelectedLevel)
  383. option.selected = '1';
  384. LSelect.add(option);
  385. }
  386. }
  387.  
  388. function abil_levels_changed()
  389. {
  390. GM_setValue('selected_level', $("#hwm_exp_abil_levels").value);
  391. }
  392.  
  393. function open_setting_form()
  394. {
  395. show_settings_base(true,
  396. '<div><b>Выберите фракцию и уровень умелки который хотите взять на этом уровне:</b></div>' +
  397. '<div><select style="width:220;" id="hwm_exp_abil_fractions"></select> Фракция</div>' +
  398. '<div><select style="width:220;" id="hwm_exp_abil_levels"></select> Уровень умелки</div>'
  399. );
  400. addEvent($('#bgOverlay' + idn), 'click', MainProcess);
  401. addEvent($('#bt_close' + idn), 'click', MainProcess);
  402.  
  403. var LFractSelect = $("#hwm_exp_abil_fractions");
  404. addEvent(LFractSelect, 'change', abil_fractions_changed);
  405. var LAllFractions = GetAllFractions();
  406. var LSelectedFract = GM_getValue('selected_fract', '');
  407. for(i = 0; i < LAllFractions.length; i++)
  408. {
  409. var LFract = LAllFractions[i];
  410. var option = document.createElement("option");
  411. option.value = LFract.Fraction;
  412. option.text = LFract.Fraction + (LFract.IsMain ? ' (Основа)' : '') +
  413. (!LFract.IsMain && LFract.IsCurrent ? ' (Играете сейчас)' : '');
  414. if ((LSelectedFract == '') && LFract.IsMain
  415. || (LSelectedFract != '') && (LFract.Fraction == LSelectedFract)
  416. )
  417. {
  418. option.selected = '1';
  419. }
  420. LFractSelect.add(option);
  421. }
  422.  
  423. var LLevelSelect = $("#hwm_exp_abil_levels");
  424. addEvent(LLevelSelect, 'change', abil_levels_changed);
  425. UpdateAbilLevels();
  426. }
  427.  
  428. function MainProcess()
  429. {
  430. var LExp = GetExp();
  431. if (expelem)
  432. {
  433. if (!$("#hwm_exp_abil_options"))
  434. {
  435. expelem.innerHTML = expelem.innerHTML + ' ' +
  436. '<a style="text-decoration:none;cursor:pointer;font-weight:bold;font-size:8px;" id="hwm_exp_abil_options">(' +
  437. '<font color="red">' +
  438. '<span id="hwm_exp_abil_el" />' +
  439. '</font>)' +
  440. '</a>';
  441. }
  442. $("#hwm_exp_abil_options").addEventListener( "click", open_setting_form , false );
  443. var LEl = $("#hwm_exp_abil_el");
  444. var LAbilityToUpInfo = GetAbilityToUpInfo();
  445. if (LAbilityToUpInfo.IsMax)
  446. {
  447. LEl.innerHTML = 'max';
  448. LEl.title =
  449. 'Вы апнули максимальную умелку фракции ' + LAbilityToUpInfo.Fraction + '\n'+
  450. 'Смените фракцию и уровень умелки который хотите взять на этом уровне';
  451. }
  452. else
  453. {
  454. var expoability = FloatFormat(LExp / LAbilityToUpInfo.AbilityToUp);
  455. LEl.innerHTML = expoability;
  456. LEl.title =
  457. 'Что б взять ' + LAbilityToUpInfo.Level + 'ю умелку фракции ' + LAbilityToUpInfo.Fraction + ' до апа уровня\n'+
  458. 'Вам нужно набрать ' + LAbilityToUpInfo.AbilityToUp + ' умения с соотношением ' + expoability;
  459. }
  460. }
  461. }
  462.  
  463. addEvent(window, 'load', MainProcess);

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址