Greasy Fork镜像 还支持 简体中文。

hwm_exp_ability

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

目前為 2015-11-29 提交的版本,檢視 最新版本

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

QingJ © 2025

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