Gateway Mods

This script adds some functions to speed up HP operations

当前为 2015-10-30 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Gateway Mods
  3. // @namespace http://www.hacker-project.com/
  4. // @version 2.3
  5. // @description This script adds some functions to speed up HP operations
  6. // @author Kevin Mitnick
  7. // @match http://www.hacker-project.com/*
  8. // @match http://hacker-project.com/*
  9. // @grant none
  10. // @require http://code.jquery.com/jquery-latest.js
  11. // ==/UserScript==
  12.  
  13. function setup() {
  14. // Setup jQuery
  15. var jQueryScript = document.createElement("script");
  16. jQueryScript.setAttribute("src", "http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js");
  17. document.head.appendChild(jQueryScript);
  18. // Add scripts
  19. var hpjsScript = document.createElement("script");
  20. hpjsScript.src = "https://rawgit.com/kbarnard2017/hp/master/hpjsy.js";
  21. hpjsScript.id = "hpjss";
  22. document.head.appendChild(hpjsScript);
  23. $("#hpjss").load(function(){ postload(); });
  24.  
  25. // COURIER NEW FONT
  26. var FONT = true;
  27.  
  28. // REMOVE DEFAULT TEXTS AND ANNOUNCEMENTS
  29. removeDTA();
  30.  
  31. if (new String(window.location.href).indexOf("&a2=try_res") > -1) {
  32. var hasGold = document.body.innerHTML.indexOf("20% Gold discount")>-1;
  33. var inputTr;
  34. var targ = document.createElement("span");
  35. targ.setAttribute("class", "p");
  36. targ.setAttribute("id", "targ");
  37. var targWrap = document.createElement("tr");
  38. targWrap.innerHTML = "<td></td>";
  39. for (var i = 0; i < document.getElementsByTagName("tr").length; i++) if (document.getElementsByTagName("tr")[i].innerHTML.indexOf("Number of hours")>-1) inputTr = document.getElementsByTagName("tr")[i];
  40. inputTr.parentNode.appendChild(targWrap);
  41. targWrap.childNodes[0].appendChild(targ);
  42. var nr_hours = document.getElementsByName("nr_hours")[0], x_times = document.getElementsByName("x_times")[0];
  43. nr_hours.addEventListener("keyup", function(){calcCost(hasGold)}, false);
  44. x_times.addEventListener("keyup", function(){calcCost(hasGold)}, false);
  45. calcCost(hasGold);
  46. }
  47.  
  48. if (new String(window.location.href).indexOf("&a2=run") > -1) {
  49.  
  50. // EXPERIMENTAL FEATURE. CAUSES EXTRA LOAD TIME FOR PROCESS PAGE. COMMENT OUT IF YOU WANT TO DISABLE
  51. // addProcs();
  52.  
  53. $(document).ready(function() {
  54. var table = document.getElementsByName("frm_files")[0].getElementsByTagName("table")[0];
  55. for (var numberOfRows = table.rows.length, i = 3; i<numberOfRows-2; i++) {
  56. var tr = table.getElementsByTagName("tbody")[0].getElementsByTagName("tr")[i];
  57. var tds = tr.getElementsByTagName("td");
  58. var content = tds[4].innerHTML;
  59. var owned = (content.indexOf("Owned")>-1);
  60. var complete = (content.indexOf("complete")>-1);
  61. var virus = (content.indexOf("virii")>-1);
  62. if (owned) tr.style.backgroundColor="#285166";
  63. if (virus && !owned) tr.style.backgroundColor="#8A0000";
  64. if (virus && owned) tr.style.backgroundColor="#511400";
  65. if (owned && complete) tr.style.backgroundColor="#004400";
  66. }
  67. });
  68. }
  69.  
  70. if (new String(window.location.href).indexOf("&a2=files") > -1) {
  71.  
  72. // Batch script
  73. var batchScript = document.createElement("script");
  74. batchScript.setAttribute("type", "text/javascript");
  75. batchScript.innerHTML = "function runPWB(pid, times, rem) { for (var i = 0; i < times; i++) { var iframe = document.createElement('iframe'); iframe.src = 'index.php?action=gate&a2=run&pid='+pid+'&rem='+rem; iframe.style.display='none'; document.body.appendChild(iframe); } }";
  76. document.body.appendChild(batchScript);
  77.  
  78. // Spec scan
  79. var psWindow = document.createElement("iframe");
  80. psWindow.src="/index.php?action=gate&a2=run";
  81. if (new String(window.location.href).indexOf("&rem=1")>-1) psWindow.src += "&rem=1";
  82. psWindow.style.display="none";
  83. psWindow.id = "psWindow";
  84. document.body.appendChild(psWindow);
  85.  
  86. $("#psWindow").load(function() {
  87. var dc = psWindow.contentWindow.document || psWindow.contentDocument || psWindow.document;
  88. var dctds = dc.getElementsByTagName("td");
  89. var specTd;
  90. for (var dci = 0; dci < dctds.length; dci++) if (dctds[dci].getElementsByTagName("span").length==10) specTd = dctds[dci];
  91. var specSpans = specTd.getElementsByTagName("span");
  92. var usedCpu = parseFloat(removeComma(specSpans[1].innerHTML));
  93. var totalCpu = parseFloat(removeComma(specSpans[2].innerHTML));
  94. var usedMem = parseFloat(removeComma(specSpans[4].innerHTML));
  95. var totalMem = parseFloat(removeComma(specSpans[5].innerHTML));
  96. var usedBand = parseFloat(removeComma(specSpans[7].innerHTML));
  97. var totalBand = parseFloat(removeComma(specSpans[8].innerHTML));
  98. var table = document.getElementsByName("frm_files")[0].getElementsByTagName("table")[0];
  99. table.getElementsByTagName("tbody")[0].appendChild(specTd);
  100. var itd = document.createElement("td");
  101. itd.innerHTML = "Executable";
  102. itd.width="100";
  103. table.getElementsByTagName("tbody")[0].getElementsByTagName("tr")[2].appendChild(itd);
  104. for (var numberOfRows = table.rows.length, i = 1; i<numberOfRows-3; i++) {
  105. var itd2 = document.createElement("td");
  106. itd.width="100";
  107. var tr = table.getElementsByTagName("tbody")[0].getElementsByTagName("tr")[i*3];
  108. var tds = tr.getElementsByTagName("td");
  109. var versionPoint = 11;
  110. if (tds[11].innerHTML=="Password Break") versionPoint = 13;
  111. var content = tds[versionPoint].getElementsByTagName("small")[0].innerHTML;
  112. var cpuNeed = parseFloat(content.substring(0, content.indexOf(" M")));
  113. var memNeed = parseFloat(content.substring(content.indexOf("U, ")+3, content.indexOf(" k")));
  114. var bandNeed = 0;
  115. if (content.indexOf("Band")>-1) bandNeed = parseFloat(content.substring(content.indexOf("M, ")+3, content.length));
  116. itd2.innerHTML = "<b><p style='color: red'>No</p></b>";
  117. if (cpuNeed<=totalCpu-usedCpu && memNeed<=totalMem-usedMem && bandNeed<=totalBand-usedBand) itd2.innerHTML = "<b><p style='color: green'>Yes</p></b>";
  118. tr.appendChild(itd2);
  119. }
  120. if (FONT) for (var x = 0; x < document.getElementsByTagName("td").length; x++) document.getElementsByTagName("td")[x].style.fontFamily="Courier New";
  121. });
  122.  
  123. var table = document.getElementsByName("frm_files")[0].getElementsByTagName("table")[0];
  124. for (var numberOfRows = table.rows.length, i = 1; i<numberOfRows-3; i++) {
  125. var tr = table.getElementsByTagName("tbody")[0].getElementsByTagName("tr")[i*3];
  126. var tds = tr.getElementsByTagName("td");
  127. var filename = tds[9].innerHTML;
  128. var versionPoint = 11;
  129. if (filename == "Password Break") versionPoint = 11;
  130. var version = parseFloat(tds[versionPoint].innerHTML);
  131.  
  132. // File type testing and calculations
  133. var usages = getUsages(filename, version);
  134. var hd, cpu, mem, band;
  135. hd = usages[0];
  136. cpu = usages[1];
  137. mem = usages[2];
  138. band = usages[3];
  139.  
  140. if (band===0) tds[versionPoint].innerHTML += ("<br/><small class='pi'> "+Math.round(version*cpu*10)+" MHz CPU, "+Math.round(version*mem*10)+" kB RAM</small>");
  141. else tds[versionPoint].innerHTML += ("<br/><small class='pi'> "+Math.round(version*cpu*10)+" MHz CPU, "+Math.round(version*mem*10)+" kB RAM, "+version*band*10+" kB/s Bandwidth</small>");
  142.  
  143. if (filename == "Password Break") {
  144. var buttonBox = tds[0];
  145. var buttonBody = buttonBox.getElementsByTagName("tbody")[0];
  146.  
  147. var tad1 = document.createElement("td");
  148. buttonBody.getElementsByTagName("tr")[0].appendChild(tad1);
  149.  
  150. var tad2 = document.createElement("td");
  151. buttonBody.getElementsByTagName("tr")[1].appendChild(tad2);
  152.  
  153. var bbutton = document.createElement("a");
  154. bbutton.innerHTML = "Batch";
  155. var bhref = buttonBody.getElementsByTagName("a")[0].getAttribute("href");
  156. var pid = bhref.substring(bhref.indexOf("pid=")+4);
  157. var rem = 0;
  158. if (bhref.indexOf("rem=1") > -1) rem = 1;
  159. var inputBox = document.createElement("input");
  160. inputBox.setAttribute("type", "number");
  161. inputBox.style.width = "50px";
  162. inputBox.id = "mpwb"+pid;
  163. tad1.appendChild(inputBox);
  164. bbutton.setAttribute("href", "javascript: runPWB("+pid+", document.getElementById('mpwb"+pid+"').value, "+rem+")");
  165. tad2.appendChild(bbutton);
  166. }
  167. }
  168.  
  169. }
  170.  
  171. if (new String(window.location.href).indexOf("?action=soft_type") > -1) {
  172.  
  173. var inputBox = document.createElement("input");
  174. inputBox.type = "number";
  175. inputBox.id = "stinp";
  176. inputBox.placeholder = "Version";
  177. inputBox.value = "0.1";
  178.  
  179. var tbodies = document.getElementsByTagName("tbody");
  180. var tb;
  181. for (var i = 0; i < tbodies.length; i++) if (tbodies[i].getElementsByTagName("td")[0].innerHTML.indexOf("Software")>-1) tb = tbodies[i];
  182. tb.id = "tbik";
  183. tb.insertBefore(inputBox, tb.getElementsByTagName("tr")[1]);
  184. tb.setAttribute("onkeyup", "updateSoftware(document.getElementById('stinp').value, document.getElementById('tbik').getElementsByTagName('tr'))");
  185. }
  186.  
  187. if (FONT) for (var x = 0; x < document.getElementsByTagName("td").length; x++) document.getElementsByTagName("td")[x].style.fontFamily="Courier New";
  188. }
  189. function updateSoftware(version, trs) {
  190. for (var i = 3; i < trs.length-1; i++) {
  191. var tds = trs[i].getElementsByTagName("td");
  192. var filename = tds[0].innerHTML;
  193. var usages = getUsages(filename, version);
  194. tds[2].innerHTML = parseFloat(usages[1]).toFixed(0);
  195. tds[3].innerHTML = parseFloat(usages[2]).toFixed(0);
  196. tds[4].innerHTML = parseFloat(usages[3]).toFixed(0);
  197. tds[5].innerHTML = parseFloat(usages[0]).toFixed(0);
  198. }
  199. }
  200. function removeComma(str) {
  201. while (str.indexOf(",") > -1) {
  202. var index = str.indexOf(",");
  203. var first = str.substring(0, index);
  204. var last = str.substring(index + 1, str.length);
  205. str = first + last;
  206. }
  207. return str;
  208. }
  209. function addProcs() {
  210. var toAdd = [];
  211. var parent = document;
  212. recurAdd(parent, toAdd);
  213. }
  214. function recurAdd(parent, toAdd) {
  215. var nextButton;
  216. var as = parent.getElementsByTagName("a");
  217. for (var i = 0; i < as.length; i++) if (as[i].childNodes[0].nodeValue == "Next") nextButton = as[i];
  218. var nBHref = nextButton.href;
  219. var table = parent.getElementsByName("frm_files")[0].getElementsByTagName("table")[0];
  220. var numProcs = 0;
  221. for (var numberOfRows = table.rows.length, i = 3; i<numberOfRows-2; i++) {
  222. if (parent != document) toAdd.push(table.getElementsByTagName("tr")[i]);
  223. numProcs++;
  224. }
  225. if (numProcs > 0) {
  226. var nextFrame = parent.createElement("iframe");
  227. nextFrame.src = nBHref+"&disable=1";
  228. nextFrame.style.display="none";
  229. nextFrame.onload = function() {
  230. recurAdd(nextFrame.contentWindow.document, toAdd);
  231. };
  232. parent.body.appendChild(nextFrame);
  233. }
  234. else {
  235. for (var i = 0; i < toAdd.length; i++) {
  236. var newNode = document.importNode(toAdd[i], true);
  237. var table = document.getElementsByName("frm_files")[0].getElementsByTagName("table")[0];
  238. var trs = table.getElementsByTagName("tr");
  239. var beforeNode;
  240. for (var l = 0; l < trs.length; l++) if (trs[l].innerHTML.indexOf("Tasks")>-1) beforeNode = trs[l];
  241. table.getElementsByTagName("tbody")[0].insertBefore(newNode, beforeNode);
  242. }
  243. }
  244. }
  245. function calcCost(gold) {
  246. var nr_hours = document.getElementsByName("nr_hours")[0], x_times = document.getElementsByName("x_times")[0], targ = document.getElementById("targ");
  247. var hours = nr_hours.value;
  248. var times = x_times.value;
  249. var mult = 100;
  250. if (gold) mult = 80;
  251. targ.innerHTML = "Estimated cost: "+hours*times*mult+" HPD";
  252. }
  253. function getUsages(filename, version) {
  254. var hd = 0, cpu = 0, mem = 0, band = 0;
  255. switch (filename) {
  256. case "Firewall Protect":{ hd = 7.50; mem = 3000; cpu = 50; band = 0; break; }
  257. case "Firewall Bypass":{ hd = 37.50; mem = 7000; cpu = 80; band = 0; break; }
  258. case "Password Protect":{ hd = 8.50; mem = 5000; cpu = 100; band = 0; break; }
  259. case "Password Break":{ hd = 84.96; mem = 12500; cpu = 200; band = 0; break; }
  260. case "Hide Files":{ hd = 100.00; mem = 9000; cpu = 100; band = 0; break; }
  261. case "Unhide Files":{ hd = 200.00; mem = 9000; cpu = 100; band = 0; break; }
  262. case "Encryptor":{ hd = 341.80; mem = 30000; cpu = 600; band = 0; break; }
  263. case "Decryptor":{ hd = 439.45; mem = 40000; cpu = 900; band = 0; break; }
  264. case "SpyWare":{ hd = 50.00; mem = 900; cpu = 300; band = 0; break; }
  265. case "Anti-SpyWare":{ hd = 100.00; mem = 22500; cpu = 150; band = 0; break; }
  266. case "Malware Logic Bomb":{ hd = 585.94; mem = 5000; cpu = 300; band = 0; break; }
  267. case "Malware Overload Bomb":{ hd = 976.56; mem = 7000; cpu = 550; band = 0; break; }
  268. case "Malware Anti-Virus":{ hd = 200.00; mem = 1500; cpu = 300; band = 0; break; }
  269. case "Adware Spam Daemon":{ hd = 100.00; mem = 5000; cpu = 50; band = 3; break; }
  270. case "Adware Anti-Virus":{ hd = 174.22; mem = 10000; cpu = 250; band = 0; break; }
  271. case "File Share Virus":{ hd = 3200.00; mem = 10000; cpu = 250; band = 50; break; }
  272. case "File Share Anti-Virus":{ hd = 1000.00; mem = 20000; cpu = 500; band = 0; break; }
  273. case "Sniffer Daemon":{ hd = 151.17; mem = 3000; cpu = 50; band = 0; break; }
  274. case "IP Cloaker":{ hd = 151.17; mem = 6000; cpu = 100; band = 0; break; }
  275. case "IP Scanner":{ hd = 369.53; mem = 10000; cpu = 200; band = 0; break; }
  276. case "Scan Blocker":{ hd = 200.00; mem = 10000; cpu = 200; band = 0; break; }
  277. case "Data uplink hijack":{ hd = 395.31; mem = 20000; cpu = 300; band = 0; break; }
  278. case "Data hijack Anti-Virus":{ hd = 200.00; mem = 30000; cpu = 500; band = 0; break; }
  279. case "Log Deleter":{ hd = 5.00; mem = 1000; cpu = 30; band = 0; break; }
  280. case "Log UnDeleter":{ hd = 15.00; mem = 3000; cpu = 50; band = 0; break; }
  281. case "Virus breaker":{ hd = 174.21; mem = 11500; cpu = 300; band = 0; break; }
  282. case "Faith Anti-Virus":{ hd = 20000.00; mem = 1200000; cpu = 20000; band = 0; break; }
  283. case "Virus Identifier":{ hd = 17.42; mem = 1150; cpu = 30; band = 0; break; }
  284. case "Process Tracer":{ hd = 174.22; mem = 92000; cpu = 2400; band = 0; break; }
  285. case "Revelation Virus":{ hd = 20000.00; mem = 600000; cpu = 10000; band = 400; break; }
  286. case "Robber Baron Virus":{ hd = 96000.00; mem = 300000; cpu = 7500; band = 1500; break; }
  287. case "Robber Baron Anti-Virus":{ hd = 30000.00; mem = 600000; cpu = 15000; band = 0; break; }
  288. case "Remote Attack Disruptor":{ hd = 174.22; mem = 92000; cpu = 2400; band = 0; break; }
  289. case "IP Leech":{ hd = 75.00; mem = 1350; cpu = 450; band = 0; break; }
  290. case "IP Leech Anti-Virus":{ hd = 150.00; mem = 21600; cpu = 225; band = 0; break; }
  291. case "Remote Virus Injector":{ hd = 4000.00; mem = 125000; cpu = 2500; band = 2; break; }
  292. case "RV Injector Anti-Virus":{ hd = 4000.00; mem = 250000; cpu = 5000; band = 0; break; }
  293. case "Overload Signer":{ hd = 174.21; mem = 92000; cpu = 2400; band = 0; break; }
  294. case "Mutant Revelation Virus":{ hd = 96000.00; mem = 3000000; cpu = 50000; band = 2000; break; }
  295. case "MutantR Accelerator":{ hd = 174.21; mem = 92000; cpu = 2400; band = 100; break; }
  296. case "MutantR Decelerator":{ hd = 174.21; mem = 278000; cpu = 9600; band = 0; break; }
  297. case "MutantR Acc Stopper":{ hd = 174.21; mem = 46000; cpu = 1200; band = 0; break; }
  298. case "MutantR Dec Stopper":{ hd = 174.21; mem = 46000; cpu = 1200; band = 0; break; }
  299. }
  300. hd *= version/0.1;
  301. mem *= version/0.1;
  302. cpu *= version/0.1;
  303. band *= version/0.1;
  304. band = band.toFixed(2);
  305. var usages = [hd, cpu, mem, band];
  306. return usages;
  307. }
  308. function removeDTA() {
  309. var as = document.getElementsByTagName("a");
  310. var spls = [];
  311. for (var i = 0; i < as.length; i++) if (as[i].getAttribute("href").indexOf("action=support")>-1 || as[i].getAttribute("href").indexOf("affiliate")>-1) spls.push(as[i]);
  312. var cont = spls.length==3;
  313. if (cont) {
  314. spls[2].parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.removeChild(spls[2].parentNode.parentNode.parentNode.parentNode.parentNode.parentNode);
  315. var fs = document.getElementsByTagName("fieldset")[0];
  316. if (new String(document.location.href).indexOf("?action=gate")>-1) {
  317. fs.removeChild(fs.childNodes[2]);
  318. fs.removeChild(fs.childNodes[2]);
  319. fs.removeChild(fs.childNodes[2]);
  320. fs.removeChild(fs.childNodes[2]);
  321. fs.removeChild(fs.childNodes[2]);
  322. }
  323. if (new String(document.location.href).indexOf("?action=ip_db")>-1) {
  324. fs.removeChild(fs.childNodes[2]);
  325. }
  326. if (new String(document.location.href).indexOf("?action=manage_tr")>-1) {
  327. fs.removeChild(fs.childNodes[2]);
  328. }
  329. if (new String(document.location.href).indexOf("?action=ability")>-1) {
  330. fs.removeChild(fs.childNodes[2]);
  331. fs.removeChild(fs.childNodes[2]);
  332. fs.removeChild(fs.childNodes[2]);
  333. fs.removeChild(fs.childNodes[2]);
  334. fs.removeChild(fs.childNodes[2]);
  335. }
  336. if (new String(document.location.href).indexOf("?action=software")>-1) {
  337. fs.removeChild(fs.childNodes[2]);
  338. fs.removeChild(fs.childNodes[2]);
  339. fs.removeChild(fs.childNodes[2]);
  340. }
  341. if (new String(document.location.href).indexOf("?action=hardware")>-1) {
  342. fs.removeChild(fs.childNodes[2]);
  343. fs.removeChild(fs.childNodes[2]);
  344. fs.removeChild(fs.childNodes[2]);
  345. }
  346. if (new String(document.location.href).indexOf("&action=pvp_board")>-1) {
  347. fs.removeChild(fs.childNodes[2]);
  348. fs.removeChild(fs.childNodes[2]);
  349. }
  350. if (new String(document.location.href).indexOf("?action=messages")>-1) {
  351. fs.removeChild(fs.childNodes[2]);
  352. fs.removeChild(fs.childNodes[2]);
  353. }
  354. if (new String(document.location.href).indexOf("?action=finances")>-1) {
  355. fs.removeChild(fs.childNodes[2]);
  356. }
  357. if (new String(document.location.href).indexOf("?action=research")>-1) {
  358. fs.removeChild(fs.childNodes[2]);
  359. fs.removeChild(fs.childNodes[2]);
  360. fs.removeChild(fs.childNodes[2]);
  361. }
  362. if (new String(document.location.href).indexOf("?action=stock_market")>-1) {
  363. fs.removeChild(fs.childNodes[2]);
  364. fs.removeChild(fs.childNodes[2]);
  365. fs.removeChild(fs.childNodes[2]);
  366. }
  367. if (new String(document.location.href).indexOf("?action=mission")>-1) {
  368. fs.removeChild(fs.childNodes[2]);
  369. }
  370. if (new String(document.location.href).indexOf("?action=faction")>-1) {
  371. fs.removeChild(fs.childNodes[2]);
  372. fs.removeChild(fs.childNodes[2]);
  373. fs.removeChild(fs.childNodes[2]);
  374. fs.removeChild(fs.childNodes[2]);
  375. fs.removeChild(fs.childNodes[2]);
  376. }
  377. if (new String(document.location.href).indexOf("?action=friend_list")>-1) {
  378. fs.removeChild(fs.childNodes[2]);
  379. }
  380. }
  381. }
  382. if (new String(window.location.href).indexOf("&disable=1")<0) setup();