presence.ts 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218
  1. const presence = new Presence({
  2. clientId: "683438933841018928",
  3. });
  4. let presenceData: PresenceData;
  5. /**
  6. * Checks whether the provided name is a valid game against a list of pathname
  7. * identifiers of games. Retrieved from https://api.nexusmods.com/v1/games.json,
  8. * doesn't get changed enough to warrant dynamic checking.
  9. *
  10. * @param {string} name The name of the game to check.
  11. * @returns {boolean} True if the game is valid, false otherwise.
  12. */
  13. function isValidGame(name: string): boolean {
  14. const validGames = [
  15. "morrowind",
  16. "oblivion",
  17. "shadowrunreturns",
  18. "skyrim",
  19. "fallout3",
  20. "newvegas",
  21. "dragonage",
  22. "dragonage2",
  23. "witcher",
  24. "xcom",
  25. "witcher2",
  26. "xrebirth",
  27. "worldoftanks",
  28. "grimrock",
  29. "darksouls",
  30. "fallenenchantress",
  31. "farcry3",
  32. "chivalry",
  33. "dungeondefenders",
  34. "neverwinter",
  35. "mountandblade",
  36. "mbwarband",
  37. "mbwithfireandsword",
  38. "minecraft",
  39. "warcraft3",
  40. "left4dead2",
  41. "kotor2",
  42. "masseffect3",
  43. "sinsofasolarempire",
  44. "saintsrow4",
  45. "stateofdecay",
  46. "fasterthanlight",
  47. "kotor",
  48. "starbound",
  49. "deusex",
  50. "masseffect",
  51. "gta4",
  52. "thief2",
  53. "zootycoon2",
  54. "mafia2",
  55. "savagexr",
  56. "masseffect2",
  57. "halo",
  58. "jurassicparkopgen",
  59. "soulreaver",
  60. "torchlight2",
  61. "gamedevtycoon",
  62. "battlefield2",
  63. "batmanarkhamorigins",
  64. "kerbalspaceprogram",
  65. "maddennfl08",
  66. "blackandwhite2",
  67. "x3terranconflict",
  68. "justcause2",
  69. "disciples3",
  70. "towns",
  71. "thesims3",
  72. "dmcdevilmaycry",
  73. "crysis",
  74. "rememberme",
  75. "rpgmakervxace",
  76. "teamfortress2",
  77. "jadeempire",
  78. "eurotrucksimulator2",
  79. "3089",
  80. "droxoperative",
  81. "risen",
  82. "crysiswarhead",
  83. "halflife2",
  84. "crusaderkings2",
  85. "borderlands",
  86. "mystonlineuru",
  87. "doom3",
  88. "arxfatalis",
  89. "thief3",
  90. "naruto3",
  91. "batmanarkhamcity",
  92. "startrekvoyagereliteforce",
  93. "cncgenerals",
  94. "cataclysmdarkdaysahead",
  95. "elderscrollsonline",
  96. "menofwar",
  97. "borderlands2",
  98. "fallout2",
  99. "southparkthestickoftruth",
  100. "rimworld",
  101. "arma3",
  102. "vampirebloodlines",
  103. "rodina",
  104. "residentevil4",
  105. "warthunder",
  106. "starwarsempireatwar",
  107. "sacred",
  108. "tabletopsimulator",
  109. "civilization4colonization",
  110. "darksouls2",
  111. "planetexplorers",
  112. "mightandmagicx",
  113. "fallenenchantresslegendaryheroes",
  114. "ageofmythologyee",
  115. "dynastywarriors8",
  116. "spaceengineers",
  117. "xenonauts",
  118. "watchdogs",
  119. "dungeonsiege1",
  120. "spintires",
  121. "insurgency",
  122. "terraria",
  123. "fallouttactics",
  124. "assettocorsa",
  125. "wizard101",
  126. "divinityoriginalsin",
  127. "carmageddonreincarnation",
  128. "piratesofthecaribbean",
  129. "projectzomboid",
  130. "warhammer40kchaosgate",
  131. "medieval2totalwar",
  132. "spore",
  133. "tug",
  134. "voidexpanse",
  135. "banished",
  136. "ageofempires",
  137. "devilmaycry3",
  138. "narutorevolution",
  139. "thesims4",
  140. "fableanniversary",
  141. "payday2",
  142. "wasteland2",
  143. "thelegendofkorra",
  144. "darkmessiahofmightandmagic",
  145. "gothic",
  146. "legendofgrimrock2",
  147. "endlesslegend",
  148. "siryouarebeinghunted",
  149. "neoscavenger",
  150. "liveforspeed",
  151. "legomarvelsuperheroes",
  152. "acepatrol",
  153. "kenshi",
  154. "dragonageinquisition",
  155. "assassinscreed",
  156. "deadstate",
  157. "metalgearsolidvgz",
  158. "rainbowsixvegas2",
  159. "farcry4",
  160. "salt",
  161. "baldursgate2ee",
  162. "evilgenius",
  163. "finalfantasy7",
  164. "worldofwarplanes",
  165. "gta3",
  166. "dyinglight",
  167. "gruntz",
  168. "darkestdungeon",
  169. "dishonored",
  170. "finalfantasy3",
  171. "saintsrow3",
  172. "civilizationbeyondearth",
  173. "voiddestroyer",
  174. "rollercoastertycoon2",
  175. "pillarsofeternity",
  176. "battlefront2",
  177. "borderlandspresequel",
  178. "cnctiberiansun",
  179. "dragonballxenoverse",
  180. "lifeistrange",
  181. "mitsurugikamuihikae",
  182. "spelunky",
  183. "deadoralive5",
  184. "gta5",
  185. "ageofempires3",
  186. "spacerangersawarapart",
  187. "spellforce1",
  188. "forceunleashed2",
  189. "dawnofwar2retribution",
  190. "wwe2k15",
  191. "tesarena",
  192. "finalfantasy14",
  193. "witcher3",
  194. "galacticcivilizations3",
  195. "gtasanandreas",
  196. "risen3",
  197. "daggerfall",
  198. "dcsworld",
  199. "devilmaycry4",
  200. "farmingsimulator2015",
  201. "sacred2",
  202. "showtime",
  203. "sorcererking",
  204. "starpointgemini2",
  205. "victoria2",
  206. "7daystodie",
  207. "batmanarkhamknight",
  208. "assassinscreedrogue",
  209. "metalgearsolidvtpp",
  210. "redfactionguerilla",
  211. "shadowrundragonfall",
  212. "shadowrunhongkong",
  213. "bigpharma",
  214. "madmax",
  215. "ageofwonders3",
  216. "delver",
  217. "maxpayne3",
  218. "fallout4",
  219. "doom2",
  220. "finalfantasy5",
  221. "fortresscraftevolved",
  222. "risen2",
  223. "robinhood",
  224. "subnautica",
  225. "sunlesssea",
  226. "thesecretofmonkeyisland",
  227. "amnesia",
  228. "blockland",
  229. "grimdawn",
  230. "sims2",
  231. "guiltygearxrd",
  232. "haloonline",
  233. "lethalleague",
  234. "starwarstheoldrepublic",
  235. "undertale",
  236. "bioshock",
  237. "hitmanbloodmoney",
  238. "psychonauts",
  239. "civilisationv",
  240. "theguild2renaissance",
  241. "dragonsdogma",
  242. "bloodandgoldcaribbean",
  243. "dragonquestheroes",
  244. "oriandtheblindforest",
  245. "unturned",
  246. "Transcendence",
  247. "bladeandsoul",
  248. "simcitysocieties",
  249. "xcom2",
  250. "americantrucksimulator",
  251. "totalannihalation",
  252. "narutoultimateninjastorm4",
  253. "thebindingofisaacrebirth",
  254. "farcryprimal",
  255. "tropico5",
  256. "alienisolation",
  257. "stardewvalley",
  258. "wwe2k16",
  259. "needforspeed2016",
  260. "startrekonline",
  261. "startrekbridgecommmander",
  262. "deadpool",
  263. "factorio",
  264. "gothic3",
  265. "planetbase",
  266. "streetfighterv",
  267. "stalkerclearsky",
  268. "tomclancysthedivision",
  269. "legostarwarsthecompletesaga",
  270. "starwarsbattlefront2015",
  271. "doom",
  272. "spidermanshattereddimensions",
  273. "darksouls3",
  274. "nexusthejupiterincident",
  275. "fableIII",
  276. "warhammer40000dawnofwar",
  277. "halflife",
  278. "masteroforionconquerthestars",
  279. "ageofempires2hd",
  280. "emperorbattlefordune",
  281. "worldinconflict",
  282. "unrealtournament3",
  283. "unrealtournament",
  284. "trackmaniaunited",
  285. "trackmanianations",
  286. "thesims",
  287. "supremecommander",
  288. "starwarsbattlefront",
  289. "prey",
  290. "fear",
  291. "flightsimulatorx",
  292. "grandtheftautovicecity",
  293. "jointoperationstyphoonrising",
  294. "left4dead",
  295. "operationflashpoint",
  296. "dayofdefeatsource",
  297. "deusexinvisiblewar",
  298. "startrekeliteforceII",
  299. "fear2projectorigin",
  300. "counterstrikeconditionzero",
  301. "civilizationiv",
  302. "callofdutyworldatwar",
  303. "blackandwhite",
  304. "battlefieldvietnam",
  305. "quake4",
  306. "lordoftheringsonlineshadowsofangmar",
  307. "themovies",
  308. "lordoftheringsbattleformiddleearth2",
  309. "operationflashpointresistance",
  310. "aliensvspredator2",
  311. "callofdutyunitedoffensive",
  312. "halo2",
  313. "returntocastlewolfenstein",
  314. "startrekstarfleetcommand3",
  315. "unrealtournament2003",
  316. "companyofheroes",
  317. "startreklegacy",
  318. "counterstrikesource",
  319. "callofduty",
  320. "worldofwarcraft",
  321. "callofduty2",
  322. "battlefield1942",
  323. "unrealtournament2004",
  324. "medalofhonor",
  325. "neverwinter2",
  326. "finalfantasyxx2hdremaster",
  327. "empyriongalacticsurvival",
  328. "europauniversalisiv",
  329. "deadisland",
  330. "joypony",
  331. "farcry2",
  332. "commandandconquerrenegade",
  333. "stalkercallofpripyat",
  334. "stalkershadowofchernobyl",
  335. "soldieroffortune2",
  336. "startrekarmada2",
  337. "callofdutyblackops2",
  338. "thiefthedarkproject",
  339. "thebannersaga",
  340. "motocrossmadness2",
  341. "fonlineashesofphoenix",
  342. "sidmeiersacepatrolpacificskies",
  343. "systemshock2",
  344. "ubersoldier2",
  345. "prisonarchitect",
  346. "samuraiwarriors2",
  347. "burnoutparadise",
  348. "stellaris",
  349. "melodysescape",
  350. "rage",
  351. "thebannersaga2",
  352. "nomanssky",
  353. "falloutshelter",
  354. "thesaboteur",
  355. "ridersoficarus",
  356. "deadspace",
  357. "divinityoriginalsin2",
  358. "leagueoflegends",
  359. "rpgmakermv",
  360. "duelyst",
  361. "deadrising",
  362. "civilisationvi",
  363. "battlebrothers",
  364. "freecol",
  365. "sakuradungeon",
  366. "shadowwarrior2",
  367. "southparkrally",
  368. "skyrimspecialedition",
  369. "stonehearth",
  370. "farmingsimulator2013",
  371. "tyranny",
  372. "residentevil6",
  373. "helgatelondon",
  374. "armacoldwarassault",
  375. "middleearthshadowofmordor",
  376. "starcrawlers",
  377. "heroesofmightandmagicv",
  378. "starwarsjediknightjediacademy",
  379. "breakingwheel",
  380. "strongholdcrusader2",
  381. "counterstrike16",
  382. "osirisnewdawn",
  383. "thelongdark",
  384. "stalkercallofchernobyl",
  385. "doorkickers",
  386. "dungeonlordssteamedition",
  387. "spellforce2",
  388. "assassinscreedii",
  389. "diablo",
  390. "thebookofunwrittentales",
  391. "escapefrompleasureplanet",
  392. "grandiaIIanniversaryedition",
  393. "doom1993",
  394. "sidmeierspirates",
  395. "totalwarshogun2",
  396. "berserkandthebandofthehawk",
  397. "halcyon6starbasecommander",
  398. "butcher",
  399. "ultimatemarvelvscapcom3",
  400. "masseffectandromeda",
  401. "rugbyleaguelive3",
  402. "streetfighteriv",
  403. "ghostreconwildlands",
  404. "castlevanialordsofshadow",
  405. "orcsmustdie2",
  406. "talesofberseria",
  407. "space",
  408. "baldursgate",
  409. "offworldtradingcompany",
  410. "justcause3",
  411. "pornostudiotycoon",
  412. "nierautomata",
  413. "finalfantasy9",
  414. "prey2017",
  415. "mirrorsedgecatalyst",
  416. "astroneer",
  417. "deusexhumanrevolution",
  418. "privateergeminigold",
  419. "titanquestanniversaryedition",
  420. "divinityoriginalsinenhancededition",
  421. "gothic2",
  422. "overwatch",
  423. "hotrodamericanstreetdrag",
  424. "icewinddale2",
  425. "kopanitoallstarssoccer",
  426. "monopoly",
  427. "saltandsanctuary",
  428. "csgo",
  429. "dungeonsiegeii",
  430. "heartsofironiv",
  431. "lifeisfeudal",
  432. "lordsofthefallen",
  433. "vermintide",
  434. "sonicmania",
  435. "endlessspace2",
  436. "mountandbladevikingconquest",
  437. "prehistorickingdom",
  438. "jaggedalliance2",
  439. "monacowhatsyoursismine",
  440. "sonicadventuredx",
  441. "batmanarkhamasylum",
  442. "finalfantasy13",
  443. "lifeisstrangebeforethestorm",
  444. "sniperghostwarrior",
  445. "tekken7",
  446. "starpointgeminiwarlords",
  447. "elex",
  448. "hacklastrecode",
  449. "assassinscreedorigins",
  450. "battlechasersnightwar",
  451. "mafia",
  452. "pavlov",
  453. "sphinxandthecursedmummy",
  454. "planttycoon",
  455. "hacknet",
  456. "spectromancer",
  457. "istaria",
  458. "riseofthetombraider",
  459. "thewalkingdead",
  460. "spaceengine",
  461. "darkandlight",
  462. "colonysurvival",
  463. "starwarsbattlefront22017",
  464. "alendadoheroi",
  465. "blazbluecentralfiction",
  466. "empiretotalwar",
  467. "garrysmod",
  468. "halocustomedition",
  469. "mesozoica",
  470. "mugen",
  471. "spacecolony",
  472. "spellforce3",
  473. "starcitizen",
  474. "turok2",
  475. "twoworlds",
  476. "legothehobbit",
  477. "handoffate2",
  478. "metro2033",
  479. "endlesssky",
  480. "site",
  481. "kingdomcomedeliverance",
  482. "dungeonbuilder",
  483. "finalfantasy12",
  484. "stationeers",
  485. "dokidokiliteratureclub",
  486. "metalgearsurvive",
  487. "mytimeatportia",
  488. "vermintide2",
  489. "intothebreach",
  490. "empireearth",
  491. "paintthetownred",
  492. "twoworldstwo",
  493. "finalfantasy15",
  494. "slaythespire",
  495. "survivingmars",
  496. "testdriveunlimited2",
  497. "farcry5",
  498. "conanexiles",
  499. "ahatintime",
  500. "contagion",
  501. "ysviii",
  502. "tombraider2",
  503. "softwareinc",
  504. "trove",
  505. "battletech",
  506. "swordcoastlegends",
  507. "pcbuildingsimulator",
  508. "pillarsofeternity2",
  509. "darksiders2deathinitiveedition",
  510. "pulsarlostcolony",
  511. "warlordsbattlecry2",
  512. "warlordsbattlecry3",
  513. "needforspeedpayback",
  514. "deusexmankinddivided",
  515. "oxygennotincluded",
  516. "themercuryman",
  517. "mnmh7",
  518. "mechwarrior4",
  519. "mortalkombat9",
  520. "footballmanager2018",
  521. "beamngdrive",
  522. "gunsgoreandcannoli2",
  523. "darksoulsremastered",
  524. "stateofdecay2",
  525. "totalwarwarhammer2",
  526. "auroradusksteamage",
  527. "kingdomsofamalurreckoning",
  528. "vampyr",
  529. "blazbluecrosstagbattle",
  530. "rugbychallenge3",
  531. "watchdogs2",
  532. "vampireredemption",
  533. "wurmunlimited",
  534. "supersmashbroswiiu",
  535. "spellforce2demonsofthepast",
  536. "crashbandicootnsanetrilogy",
  537. "bayonetta",
  538. "deadspace2",
  539. "hawx2",
  540. "shiningresonancerefrain",
  541. "spellforce2masterofwar",
  542. "middleearthshadowofwar",
  543. "terratech",
  544. "brawlhalla",
  545. "metrolastlightredux",
  546. "redfactionarmageddon",
  547. "warhammer40000gladiusrelicsofwar",
  548. "sniperghostwarrior3",
  549. "metro2033redux",
  550. "metrolastlight",
  551. "necropolis",
  552. "objectsinspace",
  553. "scpcontainmentbreach",
  554. "hitmanabsolution",
  555. "titanfall2",
  556. "splintercellconviction",
  557. "callofdutyinfinitewarfare",
  558. "monsterhunterworld",
  559. "xmenoriginswolverine",
  560. "redfactionguerrillaremarstered",
  561. "hexenii",
  562. "demonsage",
  563. "beatsaber",
  564. "fateextella",
  565. "callofdutywwii",
  566. "dyinglightbadblood",
  567. "riseofindustry",
  568. "shenmue",
  569. "shenmue2",
  570. "twopointhospital",
  571. "divinityoriginalsin2definitiveedition",
  572. "enclave",
  573. "jurassicworldevolution",
  574. "zoneoftheendersthe2ndrunnermars",
  575. "spellforceplatinumedition",
  576. "ysmemoriesofcelceta",
  577. "shadowofthetombraider",
  578. "skyrimnintendoswitch",
  579. "thebardstaleivbarrowsdeep",
  580. "starcontrolorigins",
  581. "dragonquestxi",
  582. "gpbikes",
  583. "inazumaelevengostrikers2013",
  584. "mysummercar",
  585. "legorockraiders",
  586. "theatheawakening",
  587. "pathfinderkingmaker",
  588. "battlefieldbadcompany2",
  589. "assassinscreedodyssey",
  590. "fifa18",
  591. "battlefield1",
  592. "generationzero",
  593. "assassinscreedunity",
  594. "carmechanicsimulator2018",
  595. "warriorsorochi4",
  596. "soulcaliburvi",
  597. "fallout76",
  598. "kingsbountydarkside",
  599. "footballmanager2019",
  600. "legostarwarsthevideogame",
  601. "ultimatespiderman",
  602. "dominions4",
  603. "pathofexile",
  604. "x4foundations",
  605. "blockscape",
  606. "justcause4",
  607. "hades",
  608. "fallout",
  609. "aragami",
  610. "starsector",
  611. "starwarsepisode1racer",
  612. "edgeofeternity",
  613. "bladeandsorcery",
  614. "galacticcivilizations2",
  615. "farmingsimulator19",
  616. "gardenpaws",
  617. "yakuza0",
  618. "talesofglory",
  619. "farmingsimulator17",
  620. "mafia3",
  621. "fellsealarbitersmark",
  622. "xplane11",
  623. "onimushawarlords",
  624. "kingdomtwocrowns",
  625. "graveyardkeeper",
  626. "hollowknight",
  627. "thebannersaga3",
  628. "superpower2",
  629. "assassinscreedrevelations",
  630. "finalfantasy8",
  631. "residentevil22019",
  632. "maddennfl19",
  633. "Desolate",
  634. "ashofgodsredemption",
  635. "subnauticabelowzero",
  636. "supermarioodyssey",
  637. "hexenbeyondheretic",
  638. "anthem",
  639. "thepurringquest",
  640. "wargroove",
  641. "bloodborne",
  642. "transformersdevastation",
  643. "supremecommander2",
  644. "thecuriousexpedition",
  645. "driversanfrancisco",
  646. "dontstarvetogether",
  647. "deadspace3",
  648. "hardtime",
  649. "farcrynewdawn",
  650. "quake2",
  651. "mightandmagicviii",
  652. "metroexodus",
  653. "pes2019",
  654. "secretofmana",
  655. "enderal",
  656. "wrcfiaworldrallychampionship",
  657. "phantomdoctrine",
  658. "thesurge",
  659. "battlefieldv",
  660. "thegenesisproject",
  661. "residentevilbiohazardhdremaster",
  662. "dawnofman",
  663. "devilmaycry5",
  664. "theamazingspiderman2",
  665. "bleed",
  666. "nioh",
  667. "derailvalley",
  668. "cuphead",
  669. "cavesofqud",
  670. "eastshade",
  671. "residentevil5goldedition",
  672. "tomclancysthedivision2",
  673. "sekiro",
  674. "astroximperium",
  675. "myexboyfriendthespacetyrant",
  676. "jumpforce",
  677. "slimerancher",
  678. "assassinscreediiiremastered",
  679. "outward",
  680. "residentevil0biohazard0hdremaster",
  681. "borderlandsgotyenhanced",
  682. "hereticshadowoftheserpentriders",
  683. "acecombat7skiesunknown",
  684. "killerisdead",
  685. "sunsetoverdrive",
  686. "turokdinosaurhunter",
  687. "darksiderswarmasterededition",
  688. "metalgearrisingrevengeance",
  689. "commandandconquer3tiberiumwars",
  690. "syndicatewars",
  691. "deathroadtocanada",
  692. "theevilwithin",
  693. "wwe2k19",
  694. "weedcraftinc",
  695. "laracroftandtheguardianoflight",
  696. "onewayheroics",
  697. "haydee",
  698. "clonedroneinthedangerzone",
  699. "metroidprime2echoesgamecube",
  700. "invisibleinc",
  701. "crysis2",
  702. "halflifesource",
  703. "thea2theshattering",
  704. "erannorthreborn",
  705. "mortalkombat11",
  706. "shovelknight",
  707. "ellerosorigins",
  708. "crysis3",
  709. "commandandconquer3kaneswrath",
  710. "residentevil1996",
  711. "anno1800",
  712. "manhunt",
  713. "yakuzakiwami2",
  714. "tombraider2013",
  715. "hitman2",
  716. "unreal2theawakening",
  717. "aplaguetaleinnocence",
  718. "skyrimplaystation4",
  719. "fallout4playstation4",
  720. "saintsrow2",
  721. "staxel",
  722. "rysesonofrome",
  723. "gigantic",
  724. "outlast",
  725. "sonicadventure2",
  726. "wolfensteintheoldblood",
  727. "wolfensteintheneworder",
  728. "stormworksbuildandrescue",
  729. "spellforce3soulharvest",
  730. "creatures",
  731. "creatures2",
  732. "creatures3",
  733. "totalwarthreekingdoms",
  734. "gridautosport",
  735. "lobotomycorporation",
  736. "fifa19",
  737. "wargamereddragon",
  738. "pathologic2",
  739. "cryofall",
  740. "bloodstainedritualofthenight",
  741. "yakuzakiwami",
  742. "thesinkingcity",
  743. "ultimatefishingsimulator",
  744. "needforspeedmostwanted2005",
  745. "battlefleetgothicarmada2",
  746. "zombieshooter2",
  747. "ageofcivilizations2",
  748. "cultistsimulator",
  749. "needforspeedworld",
  750. "celeste",
  751. "endcyclevs",
  752. "fortheking",
  753. "motorsportmanager",
  754. "totalwarrome2",
  755. "battlegrounds3",
  756. "shatteredtaleoftheforgottenking",
  757. "wrc5",
  758. "assassinscreedsyndicate",
  759. "callofdutyadvancedwarfare",
  760. "gloomhaven",
  761. "wrc7",
  762. "heroesofmightandmagiciii",
  763. "residentevil21998",
  764. "mightandmightvi",
  765. "lightningreturnsfinalfantasy13",
  766. "satisfactory",
  767. "enslavedodysseytothewest",
  768. "warsandwarriorsjoanofarc",
  769. "ballisticng",
  770. "dishonored2",
  771. "strandeddeep",
  772. "theevilwithin2",
  773. "rebelgalaxyoutlaw",
  774. "holdfastnationsatwar",
  775. "ageofwondersplanetfall",
  776. "daggerfallunity",
  777. "remnantfromtheashes",
  778. "ascepticsguidetomagic",
  779. "oninaki",
  780. "underrailexpedition",
  781. "control",
  782. "blairwitch",
  783. "monstersanctuary",
  784. "ninjablade",
  785. "openttd",
  786. "hiveswapfriendsim",
  787. "spyroreignitedtrilogy",
  788. "clivebarkersjericho",
  789. "shortesttriptoearth",
  790. "greedfall",
  791. "finalfantasy8remastered",
  792. "demonssouls",
  793. "blasphemous",
  794. "wizardry8",
  795. "mordhau",
  796. "maddennfl20",
  797. "borderlands3",
  798. "devilshunt",
  799. "thesurge2",
  800. "stronghold2",
  801. "greenhell",
  802. "shadowsawakening",
  803. "halothemasterchiefcollection",
  804. "codevein",
  805. "wrc8",
  806. "darkwood",
  807. "rebelgalaxy",
  808. "thepunisher",
  809. "lovethyselfahoratiostory",
  810. "huntshowdown",
  811. "recoredefinitiveedition",
  812. "warsaw",
  813. "cubeworld",
  814. "trine4thenightmareprince",
  815. "valfaris",
  816. "assassinscreedivblackflag",
  817. "residentevil5",
  818. "mechandmercsblacktalons",
  819. "azure",
  820. "fantasygeneral2",
  821. "reddeadredemption2",
  822. "discoelysium",
  823. "ghostreconbreakpoint",
  824. "legendofzeldabreathofthewild",
  825. "theouterworlds",
  826. "starwarsrepubliccommando",
  827. "splintercellblacklist",
  828. "darksiders3",
  829. "noita",
  830. "tombraiderlegend",
  831. "untitledgoosegame",
  832. "roguelands",
  833. "warhammer40000spacemarine",
  834. "callofdutymodernwarfare",
  835. "thetechnomancer",
  836. "themasterplan",
  837. "dirt3",
  838. "wildermyth",
  839. "mechwarrioronline",
  840. "starwarsjedifallenorder",
  841. "condemnedcriminalorigins",
  842. "terminatorresistance",
  843. "deadrising3",
  844. "yanderesimulator",
  845. "osu",
  846. "legendofzeldatwilightprincess",
  847. "uboat",
  848. "gun",
  849. "flatoutultimatecarnage",
  850. "warhammer40000dawnofwarII",
  851. "needforspeedheat",
  852. "bioshockinfinite",
  853. "shenmue3",
  854. "keplerth",
  855. "ageofempires2definitiveedition",
  856. "citiesskylines",
  857. "talesofsymphonia",
  858. "ambersairline7wonders",
  859. "planetzoo",
  860. "mechwarrior5mercenaries",
  861. "darksidersgenesis",
  862. "phoenixpoint",
  863. "transportfever2",
  864. "runeii",
  865. "shadowman",
  866. "thetownoflight",
  867. "bloonstd5",
  868. "racedrivergrid",
  869. "neonchrome",
  870. "freemanguerrillawarfare",
  871. "undermine",
  872. "boneworks",
  873. "sinsofthefathers20thanniversaryedition",
  874. "killingfloor",
  875. "overload",
  876. "portal2",
  877. "outerwilds",
  878. "omertacityofgangsters",
  879. "terminatorsalvation",
  880. "blackmesa",
  881. "residentevil7",
  882. "lowmagicage",
  883. "session",
  884. "howtosurvive2",
  885. "atomrpg",
  886. "zumadeluxe",
  887. "castlevaniaanniversarycollection",
  888. "howtosurvive",
  889. "sdgundamggenerationcrossrays",
  890. "legobatman",
  891. "toukiden2",
  892. "thiswarofmine",
  893. "residentevilrevelations",
  894. "dragonballzkakarot",
  895. "vanquish",
  896. "kingsbountythelegend",
  897. "dragonballxenoverse2",
  898. "nimbatusthespacedroneconstructor",
  899. "prototype",
  900. "heroesandgenerals",
  901. "callofcthulhudarkcornersoftheearth",
  902. "singularity",
  903. "2dark",
  904. "houseparty",
  905. "soldiersheroesofworldwar2",
  906. "vikingswolvesofmidgard",
  907. "callofjuarezgunslinger",
  908. "laracroftgo",
  909. "thehuntercallofthewild",
  910. "lethalleagueblaze",
  911. "rage2",
  912. "wolcenlordsofmayhem",
  913. "metalunit",
  914. "plagueincevolved",
  915. "mountandblade2bannerlord",
  916. ];
  917. return validGames.includes(name);
  918. }
  919. /**
  920. * Since Nexus Mods is relatively RESTful, we can easily re-use some basic logic to
  921. * retrieve valid presence data. This function translates the URL pathname from a
  922. * RESTful game URL to an updated presenceData instance.
  923. *
  924. * @param {Array} path The current location pathname split by "/".
  925. * @param {object} presenceData The current instance of the presence data.
  926. * @param {string} pageTitle The appropriate parsed <h1> element of the page.
  927. * @param {string} gameTitle The appropriate parsed game title element of the page.
  928. * @param {string} typeUrl The URL pathname of the resource to categorize.
  929. * @param {string} typeSingle A readable singular identifier of the resource for display.
  930. * @param {string} typePlural A readable plural identifier of the resource for display.
  931. * @returns {object} The updated instance of presence data.
  932. */
  933. function getCategorizedPresenceData(
  934. path: string[],
  935. presenceData: PresenceData,
  936. pageTitle: string,
  937. gameTitle: string,
  938. typeUrl: string,
  939. typeSingle: string,
  940. typePlural: string
  941. ): PresenceData {
  942. if (
  943. path.length > 3 &&
  944. path[0] !== "" &&
  945. path[1] === typeUrl &&
  946. path[2] === "categories" &&
  947. parseInt(path[3])
  948. ) {
  949. // Example: /game/mods/categories/1
  950. presenceData.details = `${gameTitle} - Viewing ${typeSingle} category`;
  951. presenceData.state = pageTitle;
  952. } else if (
  953. path.length > 3 &&
  954. path[0] !== "" &&
  955. path[1] === typeUrl &&
  956. path[2] === "categories" &&
  957. path[3] !== ""
  958. ) {
  959. // Example: /game/mods/categories/random
  960. presenceData.details = `${gameTitle} - Browsing ${typeSingle} categories`;
  961. presenceData.state = pageTitle;
  962. } else if (
  963. path.length > 2 &&
  964. path[0] !== "" &&
  965. path[1] === typeUrl &&
  966. path[2] === "categories"
  967. ) {
  968. // Example: /game/mods/categories
  969. presenceData.details = `${gameTitle} - Browsing ${typeSingle} categories`;
  970. } else if (
  971. path.length > 2 &&
  972. path[0] !== "" &&
  973. path[1] === typeUrl &&
  974. path[2] === "add"
  975. ) {
  976. // Example: /game/mods/add
  977. presenceData.details = `${gameTitle} - Uploading a new ${typeSingle}`;
  978. presenceData.smallImageKey = Assets.Writing;
  979. } else if (
  980. path.length > 2 &&
  981. path[0] !== "" &&
  982. path[1] === typeUrl &&
  983. path[2] !== "categories" &&
  984. parseInt(path[2])
  985. ) {
  986. // Example: /game/mods/1
  987. presenceData.details = `${gameTitle} - Viewing ${typeSingle}`;
  988. presenceData.state = pageTitle;
  989. } else if (
  990. path.length > 2 &&
  991. path[0] !== "" &&
  992. path[1] === typeUrl &&
  993. path[2] !== "categories" &&
  994. path[2] !== ""
  995. ) {
  996. // Example: /game/mods/random
  997. presenceData.details = `${gameTitle} - Browsing ${typePlural}`;
  998. presenceData.state = pageTitle;
  999. } else if (path.length > 1 && path[0] !== "" && path[1] === typeUrl) {
  1000. // Example: /game/mods
  1001. presenceData.details = `${gameTitle} - Browsing ${typePlural}`;
  1002. } else {
  1003. // Fallback
  1004. presenceData.details = `${gameTitle} - Browsing page`;
  1005. }
  1006. return presenceData;
  1007. }
  1008. const browsingTimestamp = Math.floor(Date.now() / 1000);
  1009. presence.on("UpdateData", () => {
  1010. const path = window.location.pathname.split("/").slice(1);
  1011. presenceData = {
  1012. largeImageKey:
  1013. "https://cdn.rcd.gg/PreMiD/websites/N/Nexus%20Mods/assets/logo.png",
  1014. smallImageKey: Assets.Reading,
  1015. startTimestamp: browsingTimestamp,
  1016. };
  1017. // Main entry point
  1018. switch (window.location.host.split(".")[0]) {
  1019. case "help":
  1020. // Domain: https://help.nexusmods.com/
  1021. // Explicitely don't do anything due to privacy being a possible concern.
  1022. presenceData.details = "Browsing support page";
  1023. break;
  1024. case "users":
  1025. // Domain: https://users.nexusmods.com/
  1026. // Explicitely don't do anything due to privacy being a possible concern.
  1027. presenceData.details = "Editing user account";
  1028. break;
  1029. case "wiki": {
  1030. // Domain: https://wiki.nexusmods.com/
  1031. let wikiTitle;
  1032. try {
  1033. wikiTitle = document.querySelector("#firstHeading").textContent;
  1034. if (parseInt(wikiTitle) > 128)
  1035. wikiTitle = `${wikiTitle.substring(0, 125)}...`;
  1036. } catch (error) {
  1037. wikiTitle = "Unknown page";
  1038. }
  1039. presenceData.details = "Reading wiki";
  1040. presenceData.state = wikiTitle;
  1041. break;
  1042. }
  1043. case "forums": {
  1044. // Domain: https://forums.nexusmods.com/
  1045. let forumTitle;
  1046. try {
  1047. forumTitle = document
  1048. .querySelectorAll("title")[0]
  1049. .textContent.replace(" - The Nexus Forums", "")
  1050. .replace("The Nexus Forums", "");
  1051. if (forumTitle === "") forumTitle = "Home";
  1052. else if (parseInt(forumTitle) > 128)
  1053. forumTitle = `${forumTitle.substring(0, 125)}...`;
  1054. } catch (error) {
  1055. forumTitle = "Unknown page";
  1056. }
  1057. presenceData.details = "Browsing forums";
  1058. presenceData.state = forumTitle;
  1059. break;
  1060. }
  1061. default: {
  1062. // Domain: https://www.nexusmods.com/ (with fallback in place)
  1063. // Get game title if available.
  1064. let gameTitle;
  1065. try {
  1066. gameTitle = document.querySelectorAll(".game-name")[0].textContent;
  1067. if (parseInt(gameTitle) > 128)
  1068. gameTitle = `${gameTitle.substring(0, 125)}...`;
  1069. } catch (error) {
  1070. gameTitle = "Unknown game";
  1071. }
  1072. // Get page title if available.
  1073. let pageTitle: string;
  1074. try {
  1075. pageTitle = document.querySelectorAll("H1")[0].textContent;
  1076. if (parseInt(pageTitle) > 128)
  1077. pageTitle = `${pageTitle.substring(0, 125)}...`;
  1078. } catch (error) {
  1079. pageTitle = "Unknown page";
  1080. }
  1081. // www. entry point
  1082. if (path.length > 0 && isValidGame(path[0])) {
  1083. // Games
  1084. if (path.length > 1 && path[1] !== "") {
  1085. switch (path[1]) {
  1086. case "mods":
  1087. presenceData = getCategorizedPresenceData(
  1088. path,
  1089. presenceData,
  1090. pageTitle,
  1091. gameTitle,
  1092. "mods",
  1093. "mod",
  1094. "mods"
  1095. );
  1096. break;
  1097. case "media":
  1098. presenceData = getCategorizedPresenceData(
  1099. path,
  1100. presenceData,
  1101. pageTitle,
  1102. gameTitle,
  1103. "media",
  1104. "media",
  1105. "media"
  1106. );
  1107. break;
  1108. case "images":
  1109. presenceData = getCategorizedPresenceData(
  1110. path,
  1111. presenceData,
  1112. pageTitle,
  1113. gameTitle,
  1114. "images",
  1115. "image",
  1116. "images"
  1117. );
  1118. break;
  1119. case "videos":
  1120. presenceData = getCategorizedPresenceData(
  1121. path,
  1122. presenceData,
  1123. pageTitle,
  1124. gameTitle,
  1125. "videos",
  1126. "video",
  1127. "videos"
  1128. );
  1129. break;
  1130. default:
  1131. presenceData.details = `${gameTitle} - Browsing page`;
  1132. break;
  1133. }
  1134. } else presenceData.details = `${gameTitle} - Browsing home`;
  1135. } else if (path.length > 0 && path[0] !== "") {
  1136. // Subpages
  1137. switch (path[0]) {
  1138. case "about":
  1139. presenceData.details = "Browsing about";
  1140. break;
  1141. case "news": {
  1142. if (path.length > 1 && parseInt(path[1])) {
  1143. presenceData.details = "Reading a news article";
  1144. presenceData.state = pageTitle;
  1145. } else presenceData.details = "Browsing news";
  1146. break;
  1147. }
  1148. case "mods": {
  1149. if (path.length > 1 && path[1] === "add") {
  1150. presenceData.details = "Uploading a new mod";
  1151. presenceData.smallImageKey = Assets.Writing;
  1152. } else presenceData.details = "Browsing mods";
  1153. break;
  1154. }
  1155. case "media":
  1156. presenceData.details = "Browsing media";
  1157. break;
  1158. case "images": {
  1159. if (path.length > 1 && path[1] === "add") {
  1160. presenceData.details = "Uploading a new image";
  1161. presenceData.smallImageKey = Assets.Writing;
  1162. } else presenceData.details = "Browsing images";
  1163. break;
  1164. }
  1165. case "videos": {
  1166. if (path.length > 1 && path[1] === "add") {
  1167. presenceData.details = "Uploading a new video";
  1168. presenceData.smallImageKey = Assets.Writing;
  1169. } else presenceData.details = "Browsing videos";
  1170. break;
  1171. }
  1172. case "games":
  1173. presenceData.details = "Browsing games";
  1174. break;
  1175. default:
  1176. presenceData.details = "Browsing page";
  1177. break;
  1178. }
  1179. } else {
  1180. // Homepage
  1181. presenceData.details = "Browsing home";
  1182. }
  1183. break;
  1184. }
  1185. }
  1186. // Set presence.
  1187. if (presenceData.details) presence.setActivity(presenceData);
  1188. else presence.setActivity();
  1189. });