Advertisement
sinrtb

common.js

Jan 27th, 2022
1,070
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. export function settings() {
  2.   return {
  3.     minSecurityLevelOffset: 2,
  4.     maxMoneyMultiplayer: 0.9,
  5.     minSecurityWeight: 100,
  6.     mapRefreshInterval: 24 * 60 * 60 * 1000,
  7.     keys: {
  8.       serverMap: 'BB_SERVER_MAP',
  9.       hackTarget: 'BB_HACK_TARGET',
  10.       action: 'BB_ACTION',
  11.     },
  12.     changes: {
  13.       hack: 0.002,
  14.       grow: 0.004,
  15.       weaken: 0.05,
  16.     },
  17.   }
  18. }
  19. /** @param {NS} ns **/
  20. export function createUUID() {
  21.   var dt = new Date().getTime()
  22.   var uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
  23.     var r = (dt + Math.random() * 16) % 16 | 0
  24.     dt = Math.floor(dt / 16)
  25.     return (c == 'x' ? r : (r & 0x3) | 0x8).toString(16)
  26.   })
  27.   return uuid
  28. }
  29.  
  30.  
  31. /** @param {NS} ns **/
  32. export function getItem(key) {
  33.   let item = localStorage.getItem(key)
  34.  
  35.   return item ? JSON.parse(item) : undefined
  36. }
  37.  
  38. /** @param {NS} ns **/
  39. export function setItem(key, value) {
  40.   localStorage.setItem(key, JSON.stringify(value))
  41. }
  42.  
  43. /** @param {NS} ns **/
  44. export function convertMSToHHMMSS(ms = 0) {
  45.   if (ms <= 0) {
  46.     return '00:00:00'
  47.   }
  48.  
  49.   if (!ms) {
  50.     ms = new Date().getTime()
  51.   }
  52.  
  53.   return new Date(ms).toISOString().substr(11, 8)
  54. }
  55.  
  56. /** @param {NS} ns **/
  57. export function localeHHMMSS(ms = 0) {
  58.   if (!ms) {
  59.     ms = new Date().getTime()
  60.   }
  61.  
  62.   return new Date(ms).toLocaleTimeString()
  63. }
  64.  
  65. /** @param {NS} ns **/
  66. export const hackPrograms = ['BruteSSH.exe', 'FTPCrack.exe', 'relaySMTP.exe', 'HTTPWorm.exe', 'SQLInject.exe']
  67.  
  68. /** @param {NS} ns **/
  69. export const hackScripts = ['hack.js', 'grow.js', 'weaken.js', '/newserver/grow.js', '/newserver/weaken.js', '/newserver/hack.js', '/newserver/OP.js', '/newserver/xs.js']
  70.  
  71. /** @param {NS} ns **/
  72. export async function main(ns) {
  73.   return {
  74.     settings,
  75.     getItem,
  76.     setItem,
  77.     createUUID,
  78.     localeHHMMSS,
  79.     convertMSToHHMMSS,
  80.     hackPrograms,
  81.     hackScripts,
  82.   }
  83. }
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement