Bloble.io NoobScript V3 QuickSelect Fragment

A fragment of code from NoobScript V3 - The quick troops selector. Press q for selecting all but commander, e for selecting everything, and c for selecting the commander.

  1. // ==UserScript==
  2. // @name Bloble.io NoobScript V3 QuickSelect Fragment
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.0
  5. // @description A fragment of code from NoobScript V3 - The quick troops selector. Press q for selecting all but commander, e for selecting everything, and c for selecting the commander.
  6. // @author NoobishHacker
  7. // @match http://bloble.io/*
  8. // @grant none
  9. // ==/UserScript==
  10. window.addEventListener("keyup", function(a) {
  11. a = a.keyCode ? a.keyCode : a.which;
  12.  
  13. if (a === 81) { // All troops except commander
  14. selUnits = [];
  15. units.forEach((unit) => {
  16. if (unit.owner === player.sid && unit.type === 1) {
  17. if (!unit.info) unit.info = getUnitFromPath(unit.uPath);
  18. unit.info.name !== 'Commander' && selUnits.push(unit)
  19.  
  20. }
  21. });
  22. selUnitType = "Unit";
  23. } else if (a === 69) { // Everything
  24. selUnits = [];
  25. units.forEach((unit) => {
  26. if (unit.owner === player.sid && unit.type === 1) {
  27. if (!unit.info) unit.info = getUnitFromPath(unit.uPath);
  28. selUnits.push(unit)
  29. }
  30. });
  31. selUnitType = "Unit";
  32. } else if (a === 67) { // Commander
  33. selUnits = [];
  34. units.every((unit) => {
  35. if (unit.owner === player.sid && unit.type === 1) {
  36. if (!unit.info) unit.info = getUnitFromPath(unit.uPath);
  37. if (unit.info.name === 'Commander') {
  38. selUnits.push(unit)
  39. return false;
  40. }
  41. }
  42. return true;
  43. });
  44. selUnitType = "Unit";
  45. }
  46. });