HWM_InstantParametersChange

Мгновенная переброска параметров до заданных значений, не требует места в инвентаре для зелья. Использована форма от похожего скрипта авторства УжеЛежу.

目前为 2016-11-15 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name HWM_InstantParametersChange
  3. // @version 1
  4. // @namespace Рианти
  5. // @description Мгновенная переброска параметров до заданных значений, не требует места в инвентаре для зелья. Использована форма от похожего скрипта авторства УжеЛежу.
  6. // @include *heroeswm*/home.php*
  7. // @include http://178.248.235.15/home.php*
  8. // @grant GM_xmlhttpRequest
  9. // ==/UserScript==
  10.  
  11. var xmlHttp = false;
  12. var host = location.host;
  13. var rst = 1;
  14.  
  15. as = document.getElementsByTagName("a");
  16. counter_stat_begin = 0;
  17. counter_stat_end = 0;
  18. tbl = false;
  19. stats_names = ["attack", "defence", "power", "knowledge"];
  20. urls = [];
  21. stats = [];
  22. counts_url = 0;
  23. inc_all = true;
  24. var tr_info = false;
  25. var tbl = false;
  26. var sendStatus = 0;
  27. var parameter_sets = [];
  28. var name_parameter_sets = [];
  29. var count_parameter_sets = 0;
  30. var tgr_stance;
  31.  
  32. imgs = document.getElementsByTagName("img");
  33. for (id_img in imgs) {
  34. img = imgs[id_img].src;
  35. if (img && img.indexOf("s_luck.gif") > -1)
  36. tr_info = imgs[id_img].parentNode.parentNode.parentNode.parentNode.parentNode.parentNode;
  37. }
  38.  
  39. td_reset = tr_info.insertCell(2);
  40. td_reset.align = "center";
  41. td_reset.style= "vertical-align: top;";
  42. style_button = "style='background-color:#F5F3EA;cursor:pointer;border-radius:4px;border:1px solid #5D413A;padding:3'";
  43. style_delete = "style='background-color:#FF0000;cursor:pointer;border-radius:4px;border:1px solid #5D413A;padding:3;color:#FFFFFF'";
  44.  
  45. function init_reset_info() {
  46. var ii = 0;
  47. parameter_sets = [];
  48. name_parameter_sets = [];
  49. for (var i = 0; i < 10; i++) {
  50. if (localStorage['parameter_sets_' + i]) {
  51. parameter_sets[ii] = localStorage['parameter_sets_' + i];
  52. name_parameter_sets[ii] = localStorage['name_parameter_sets_' + i];
  53. if (i > ii) {
  54. delete localStorage['parameter_sets_' + i];
  55. localStorage['parameter_sets_' + ii] = parameter_sets[ii];
  56. delete localStorage['name_parameter_sets_' + i];
  57. localStorage['name_parameter_sets_' + ii] = name_parameter_sets[ii];
  58. }
  59. ii++;
  60. }
  61. }
  62.  
  63. count_parameter_sets = parameter_sets.length;
  64. reset_info = "<table width=100%>";
  65. reset_info += "<tr align='center'><td colspan=7 " + style_button + " id=reset>Сбросить параметры</td></tr>";
  66. reset_info += "<tr align='center'><td colspan=7 " + style_button + " id=tgr_switch>Наборы статов</td></tr>";
  67. {
  68. reset_info += "<tr align='center' class='tgr'><td colspan=7>Наборы параметров:</td></tr>";
  69. if (parameter_sets.length == 0) {
  70. reset_info += "<tr align='center' class='tgr'><td colspan=6>0 наборов</td></tr>";
  71. } else {
  72. for (var j = 0; j < parameter_sets.length; j++) {
  73. set_infos = parameter_sets[j].split(".");
  74. set_info = "";
  75. for (var k = 0; k < set_infos.length; k++) {
  76. if (set_infos[k] / 1 > 0) {
  77. set_info += "+<b>" + set_infos[k] + "</b><img width=15 src='http://dcdn.heroeswm.ru/i/s_" + stats_names[k] + ".gif'>";
  78. }
  79. }
  80. set_info = set_info.substr(1);
  81. set_info = (j + 1) + ". " + name_parameter_sets[j] + " " + "<span style='font-size:11px'>[" + set_info + "]</span>";
  82. reset_info += "<tr align='center' class='tgr'>";
  83. reset_info += "<td colspan=5 align=left>" + set_info + "</td>";
  84. reset_info += "<td id=apply_set_" + j + " " + style_button + " width=10 title='Применить'><b>(+)</b></td>";
  85. reset_info += "<td id=delete_set_" + j + " " + style_delete + " width=10 title='Удалить'><b>X</b></td>";
  86. reset_info += "</tr>";
  87. }
  88. }
  89. reset_info += "<tr align='center' class='tgr'><td colspan=7>Добавить набор:</td></tr>";
  90. reset_info += "<tr align='center' class='tgr'>";
  91. reset_info += "<td>Имя</td>";
  92. reset_info += "<td><img src='http://dcdn.heroeswm.ru/i/s_attack.gif'></td>";
  93. reset_info += "<td><img src='http://dcdn.heroeswm.ru/i/s_defence.gif'></td>";
  94. reset_info += "<td><img src='http://dcdn.heroeswm.ru/i/s_power.gif'></td>";
  95. reset_info += "<td><img src='http://dcdn.heroeswm.ru/i/s_knowledge.gif'></td>";
  96. reset_info += "<td id=add_set rowspan=2 colspan=2 " + style_button + ">Добавить</td>";
  97. reset_info += "</tr>";
  98. reset_info += "<tr align='center' class='tgr'>";
  99. reset_info += "<td><input id=set_name type=text size=10 maxlength=8></td>";
  100. reset_info += "<td><input id=set_a type=text size=1></td>";
  101. reset_info += "<td><input id=set_d type=text size=1></td>";
  102. reset_info += "<td><input id=set_p type=text size=1></td>";
  103. reset_info += "<td><input id=set_k type=text size=1></td>";
  104. reset_info += "</tr>";
  105. reset_info += "</table>";
  106. td_reset.innerHTML = reset_info;
  107. for (var k = 0; k < parameter_sets.length; k++) {
  108. $('apply_set_' + k).addEventListener(
  109. "click",
  110. function () {
  111. var id = this.id;
  112. count_set = id.split("_")[2];
  113. set_infos = parameter_sets[count_set].split(".");
  114. quickApplyParams(set_infos);
  115. }
  116. );
  117. $('delete_set_' + k).addEventListener(
  118. "click",
  119. function () {
  120. var id = this.id;
  121. count_set = id.split("_")[2];
  122. console.log(localStorage['parameter_sets_' + count_set]);
  123. if (localStorage['parameter_sets_' + count_set]) {
  124. localStorage.removeItem('parameter_sets_' + count_set);
  125. localStorage.removeItem('name_parameter_sets_' + count_set);
  126. console.log(localStorage['parameter_sets_' + count_set]);
  127. init_reset_info();
  128. }
  129. }
  130. );
  131. }
  132. $('add_set').onclick = add_set;
  133. }
  134. $('reset').onclick = reset_parameters;
  135. $('tgr_switch').onclick = toggle_setups;
  136. if(tgr_stance == null){
  137. tgr_stance = 1;
  138. toggle_setups();
  139. }
  140. }
  141.  
  142. init_reset_info();
  143.  
  144. function $( id ) {
  145. return document.getElementById( id );
  146. }
  147.  
  148. function toggle_setups(){
  149. tgr_stance = (tgr_stance + 1) % 2;
  150. var tgr_rows = document.querySelectorAll('tr[class="tgr"]'),
  151. rid;
  152. for (rid = 0; rid < tgr_rows.length; rid++){
  153. if(!tgr_stance) tgr_rows[rid].style = 'visibility: collapse;';
  154. else tgr_rows[rid].style = 'visibility: initial;';
  155. }
  156. }
  157.  
  158. function startAjax() {
  159. if (!xmlHttp && typeof XMLHttpRequest != 'undefined')
  160. xmlHttp = new XMLHttpRequest();
  161. }
  162.  
  163. function send(url, afterSend) {
  164. xmlHttp.open("GET", url, true);
  165. xmlHttp.onreadystatechange = afterSend;
  166. xmlHttp.send(null);
  167. }
  168.  
  169. function afterSend() {
  170. rst = xmlHttp.readyState;
  171. if (xmlHttp.readyState == 4) {
  172. if (xmlHttp.status == 200) {
  173. if (sendStatus == 1) {
  174. sign = xmlHttp.responseText.split("sign=");
  175. sign = sign[1].substr(0, sign[1].indexOf("\""));
  176. if (sign) {
  177. send("http://" + host + "/shop.php?b=reset_tube&cat=potions&sign=" + sign, afterSend);
  178. sendStatus = 2;
  179. }
  180. } else if (sendStatus == 2) {
  181. send("http://" + host + "/inventory.php", afterSend);
  182. sendStatus = 3;
  183. } else if (sendStatus == 3) {
  184. text = xmlHttp.responseText;
  185. reset_tube = text.split("id=reset_tube");
  186. reset_tube = reset_tube[1].split("?dress=");
  187. reset_tube = reset_tube[1].substr(0, reset_tube[1].indexOf("'"));
  188. if (reset_tube) {
  189. send("http://" + host + "/inventory.php?dress=" + reset_tube, afterSend);
  190. sendStatus = 4;
  191. }
  192. } else if (sendStatus == 4) {
  193. location.href = "http://" + host + "/home.php";
  194. } else {
  195. counter_stat_end++;
  196. $("progress_stats").style.width = counter_stat_end * 100 / points + "%";
  197. $("progress_stats").innerHTML = "<b>" + counter_stat_end + "/" + points + "</b>";
  198. if (counter_stat_end == points)
  199. location.href = "http://" + host + "/home.php";
  200.  
  201. console.log(stats[counter_stat_end - 1]);
  202. n = tbl.rows[stats[counter_stat_end - 1]].cells[2].innerHTML;
  203. n = n.substr(n.indexOf("+") + 1);
  204. n = n.substr(0, n.indexOf("<"));
  205. tbl.rows[stats[counter_stat_end - 1]].cells[2].innerHTML = "<b style='color:red'>&nbsp;+" + (n / 1 + 1) + "</b>";
  206. m = tbl.rows[4].cells[0].innerHTML;
  207. m = m.substr(m.lastIndexOf(" ") + 1);
  208. console.log("m = '" + m + "'");
  209. tbl.rows[4].cells[0].innerHTML = "<b>Свободных очков от навыка:</b> " + (m / 1 - 1);
  210. rst = 0;
  211. }
  212. }
  213. }
  214. }
  215.  
  216. function reset_parameters() {
  217. send("http://" + host + "/shop.php?cat=potions", afterSend);
  218. $("reset").innerHTML = "Сбросить параметры <img width=15 src='http://dcdn2.heroeswm.ru/i/loading.gif'>";
  219. sendStatus = 1;
  220. }
  221.  
  222. function add_set() {
  223. var parameter_set = ($('set_a').value ? $('set_a').value : 0) + ".";
  224. parameter_set += ($('set_d').value ? $('set_d').value : 0) + ".";
  225. parameter_set += ($('set_p').value ? $('set_p').value : 0) + ".";
  226. parameter_set += ($('set_k').value ? $('set_k').value : 0);
  227. localStorage['parameter_sets_' + count_parameter_sets] = parameter_set;
  228. localStorage['name_parameter_sets_' + count_parameter_sets] = $('set_name').value ? $('set_name').value : "Набор" + (count_parameter_sets + 1);
  229. init_reset_info();
  230. }
  231.  
  232. function quickApplyParams(stats) {
  233. var attack = parseInt(stats[0]),
  234. defence = parseInt(stats[1]),
  235. SM = parseInt(stats[2]),
  236. knowlege = parseInt(stats[3]);
  237.  
  238. requestPage ('http://www.heroeswm.ru/skillwheel.php', function (dom) {
  239. var curPerks = dom.querySelector('object[classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"] param[name="FlashVars"]').value.split('|');
  240. curPerks[0] = curPerks[0].split('$');
  241. curPerks[0] = '$' + curPerks[0][curPerks[0].length - 1];
  242. var chosenPerks = [];
  243.  
  244. for (var i = 8; i < curPerks.length; i += 9)
  245. if(curPerks[i] == '1') chosenPerks.push(curPerks[i - 8].replace('$', ''));
  246.  
  247. var params = '', buildperks0 = '', t;
  248.  
  249. for (var p = 0; p <=30; p++) {
  250. if(chosenPerks.length) {
  251. t = chosenPerks.shift();
  252. params = 'param' + p + '=' + t + '&' + params;
  253. buildperks0 += t + '%3B';
  254. } else {
  255. params = 'param' + p + '=&' + params;
  256. }
  257. }
  258. var enlightenmentStats = Math.floor(parseInt(document.body.innerHTML.match(/Боевой уровень: (\d+)/)[1]) / new Object({0: 99, 1: 4, 2: 3, 3: 2})[(buildperks0.match(/enlightenment/g) || []).length]);
  259. var maxStatId = [{i: 0, v: attack}, {i: 1, v: defence}, {i: 2, v: SM}, {i: 3, v: knowlege}].sort(function(a,b){return b.v > a.v})[0].i;
  260. var enlightenmentString = 'pstat3=0&pstat2=0&pstat1=0&pstat0=0'.replace('pstat' + maxStatId + '=0', 'pstat' + maxStatId + '=' + enlightenmentStats);
  261.  
  262. var postVars = 'loading=true&rand=0%2E521691998932511&reset%5Fall=0&setall=1&setpstats=' + (enlightenmentStats > 0 ? 1 : 0) + '&' + params + 'buildperks0=' + buildperks0 + '&buildbaseid0=7&buildname0=&setstats=1&stat3=' + knowlege + '&stat2=' + SM + '&stat1=' + defence + '&stat0=' + attack + '&' + enlightenmentString + '&onData=%5Btype%20Function%5D';
  263. applyChanges('http://www.heroeswm.ru/skillwheel.php', postVars);
  264. });
  265. }
  266.  
  267. function applyChanges(url, params) {
  268. var xmlhttp = new XMLHttpRequest();
  269. xmlhttp.open('POST', url, true);
  270. xmlhttp.overrideMimeType('text/plain; charset=windows-1251');
  271. xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
  272. xmlhttp.send(params);
  273. xmlhttp.onreadystatechange = function() {
  274. if(xmlhttp.status == 200)
  275. document.location.reload();
  276. }
  277. }
  278.  
  279. function requestPage (url, onloadHandler) {
  280. console.log('[HWM_InstantParametersChange] loading: ', url);
  281. GM_xmlhttpRequest({
  282. overrideMimeType: 'text/plain; charset=windows-1251',
  283. synchronous: false,
  284. url: url,
  285. method: "GET",
  286. onload: function(response) {
  287. onloadHandler(new DOMParser().parseFromString(response.responseText, 'text/html').documentElement);
  288. },
  289. onerror: function() { requestPage (url, onloadHandler) },
  290. ontimeout: function() { requestPage (url, onloadHandler) },
  291. timeout: 5000
  292. });
  293. }
  294.  
  295. startAjax();

QingJ © 2025

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