@@ -29,39 +29,42 @@ const Utils = require('../util/utils.js');
2929
3030const SLEEP_TIMEOUT_MS = 2000 ;
3131
32- const RUSTLABS_ALL_ITEMS_URL = 'https://rustlabs .com/group=itemlist' ;
33- const RUSTLABS_ITEM_URL = 'https://rustlabs .com/item/' ;
32+ const RUSTLABS_ALL_ITEMS_URL = 'https://wiki.rustclash .com/group=itemlist' ;
33+ const RUSTLABS_ITEM_URL = 'https://wiki.rustclash .com/item/' ;
3434
35- const RUSTLABS_ALL_LOOT_CONTAINERS_URL = 'https://rustlabs .com/group=containers' ;
36- const RUSTLABS_ENTITY_URL = 'https://rustlabs .com/entity/' ;
35+ const RUSTLABS_ALL_LOOT_CONTAINERS_URL = 'https://wiki.rustclash .com/group=containers' ;
36+ const RUSTLABS_ENTITY_URL = 'https://wiki.rustclash .com/entity/' ;
3737
38- const RUSTLABS_ALL_BUILDING_BLOCKS_URL = 'https://rustlabs .com/group=building-blocks' ;
39- const RUSTLABS_BUILDING_BLOCK_URL = 'https://rustlabs .com/building/' ;
38+ const RUSTLABS_ALL_BUILDING_BLOCKS_URL = 'https://wiki.rustclash .com/group=building-blocks' ;
39+ const RUSTLABS_BUILDING_BLOCK_URL = 'https://wiki.rustclash .com/building/' ;
4040
41- const RUSTLABS_ALL_OTHER_URL = 'https://rustlabs .com/group=else' ;
42- const RUSTLABS_OTHER_URL = 'https://rustlabs .com/entity/' ;
41+ const RUSTLABS_ALL_OTHER_URL = 'https://wiki.rustclash .com/group=else' ;
42+ const RUSTLABS_OTHER_URL = 'https://wiki.rustclash .com/entity/' ;
4343
4444
4545const RUSTLABS_ALL_ITEMS_REGEX = / < a \s h r e f = " \/ i t e m \/ ( .* ?) " \s c l a s s .* ?i m g \s s r c = .* ?i m g \/ .* ?\/ ( .* ?) \. p n g " \s a l t = " ( .* ?) " / gm
46- const RUSTLABS_ITEM_RECYCLE_AREA_REGEX = / R e c y c l e r < \/ a > < \/ t d > \n ^ .* ?$ \n ^ .* ?$ \n < \/ t d > / gm
47- const RUSTLABS_ITEM_RECYCLE_REGEX = / < a \s h r e f .* ?i m g \/ .* ?\/ ( .* ?) \. p n g .* ?a l t = " ( .* ?) " .* ?t e x t - i n - i c o n " > ( .* ?) < \/ s p a n > < \/ a > / gm
46+ const RUSTLABS_ITEM_RECYCLE_AREA_REGEX = / R e c y c l e r < \/ t h > ( \n | .) * ?< \/ t a b l e > / gm
47+ const RUSTLABS_ITEM_RECYCLE_ROW_REGEX = / < t d c l a s s = " l e f t " > ( \n | .) * ?< \/ t r > / gm
48+ const RUSTLABS_ITEM_RECYCLE_ITEM_REGEX = / \/ e n t i t y \/ ( .* ?) " / gm
49+ const RUSTLABS_ITEM_RECYCLE_ITEM_EFFICIENCY_REGEX = / < t d \s d a t a - v a l u e = " ( .* ?) " > .* ?% < \/ t d > / gm
50+ const RUSTLABS_ITEM_RECYCLE_OUTPUT_ITEMS_REGEX = / < a \s h r e f .* ?i m g \/ .* ?\/ ( .* ?) \. p n g .* ?a l t = " ( .* ?) " .* ?t e x t - i n - i c o n " > ( .* ?) < \/ s p a n > < \/ a > / gm
4851
4952const RUSTLABS_ITEM_CRAFT_AREA_REGEX = / d a t a - n a m e = " c r a f t " \s c l a s s = " t a b - p a g e ( \n | .) * ?< \/ t h e a d ( \n | .) * ?< \/ t r > / gm
5053const RUSTLABS_ITEM_CRAFT_INGREDIENTS_REGEX =
5154 / < a \s h r e f .* ?i m g \/ .* ?\/ ( .* ?) \. p n g .* ?a l t = " ( .* ?) " .* ?t e x t - i n - i c o n " > ( .* ?) < \/ s p a n > < \/ a > / gm
52- const RUSTLABS_ITEM_CRAFT_TIME_REGEX = / ^ < t d \s d a t a - v a l u e = " ( .* ?) " > ( .* ?) < \/ t d > $ / gm
55+ const RUSTLABS_ITEM_CRAFT_TIME_REGEX = / ^ \s * < t d \s d a t a - v a l u e = " ( .* ?) " > ( .* ?) < \/ t d > / gm
5356
5457const RUSTLABS_ITEM_RESEARCH_AREA_REGEX =
5558 / d a t a - n a m e = " b l u e p r i n t " \s c l a s s = " t a b - p a g e ( \n | .) * ?< t a b l e \s c l a s s ( \n | .) * ?< \/ t a b l e > / gm
5659const RUSTLABS_ITEM_RESEARCH_ROW_REGEX = / < t d \s c l a s s = " i t e m - c e l l " > ( \n | .) * ?< \/ t r > / gm
5760const RUSTLABS_ITEM_RESEARCH_TYPE_REGEX =
58- / < t d \s c l a s s = " i t e m - c e l l " > ( \n | .) * ?< i m g \s c l a s s \s s r c = " ( \n | .) * ?i m g \/ ( \n | .) * ?\/ ( .* ?) \. p n g / gm
61+ / < t d \s c l a s s = " i t e m - c e l l " > ( \n | .) * ?< i m g \s c l a s s = " " \s s r c = " ( \n | .) * ?i m g \/ ( \n | .) * ?\/ ( .* ?) \. p n g / gm
5962const RUSTLABS_ITEM_RESEARCH_SCRAP_REGEX = / \/ s c r a p \. p n g ( \n | .) * ?c l a s s = " t e x t - i n - i c o n " > ( .* ?) < \/ s p a n > / gm
6063const RUSTLABS_ITEM_RESEARCH_TOTAL_SCRAP_REGEX = / < t d \s c l a s s = " n o - p a d d i n g " \s d a t a - v a l u e = " ( .* ?) " > / gm
6164
6265const RUSTLABS_ITEM_DURABILITY_AREA_REGEX1 = / < t r \s d a t a - g r o u p = " ( .* ?) " \s d a t a - g r o u p 2 = " ( .* ?) " > ( \n | .) * ?< \/ t r > / gm
6366const RUSTLABS_ITEM_DURABILITY_AREA_REGEX2 = / < t r \s d a t a - g r o u p = " ( .* ?) " > ( \n | .) * ?< \/ t r > / gm
64- const RUSTLABS_ITEM_DURABILITY_TOOL_REGEX = / < i m g \s c l a s s \s s r c = " .* ?\/ i m g \/ .* ?\/ ( .* ?) \. p n g " \s a l t = " ( .* ?) " > / gm
67+ const RUSTLABS_ITEM_DURABILITY_TOOL_REGEX = / < i m g \s c l a s s = " " \s s r c = " .* ?\/ i m g \/ .* ?\/ ( .* ?) \. p n g " \s a l t = " ( .* ?) " > / gm
6568const RUSTLABS_ITEM_DURABILITY_CAPTION_IN_TOOL_REGEX = / c a p t i o n - i n - i t e m - n a m e " > ( .* ?) < / gm
6669const RUSTLABS_ITEM_DURABILITY_QUANTITY_REGEX = / < t d \s c l a s s = " n o - p a d d i n g " \s d a t a - v a l u e = " ( \d { 1 , 7 } ) " > ( .{ 1 , 10 } ) < \/ t d > / gm
6770const RUSTLABS_ITEM_DURABILITY_QUANTITY_APPROX_REGEX = / A p p r o x i m a t e \s Q u a n t i t y " > ( .* ?) < / gm
@@ -469,39 +472,72 @@ function processItemRecycle(rustlabsName, shortname, name, data) {
469472 }
470473 data = data [ 0 ] ;
471474
472- const matches = data . matchAll ( RUSTLABS_ITEM_RECYCLE_REGEX ) ;
473- const recycleItems = [ ] ;
474-
475- for ( const match of matches ) {
476- if ( match . length !== 4 ) exit ( ) ;
475+ const recycleData = new Object ( ) ;
476+ recycleData [ 'recycler' ] = new Object ( ) ;
477+ recycleData [ 'recycler' ] [ 'efficiency' ] = null ;
478+ recycleData [ 'recycler' ] [ 'yield' ] = [ ] ;
479+ recycleData [ 'shredder' ] = new Object ( ) ;
480+ recycleData [ 'shredder' ] [ 'efficiency' ] = null ;
481+ recycleData [ 'shredder' ] [ 'yield' ] = [ ] ;
482+ recycleData [ 'safe-zone-recycler' ] = new Object ( ) ;
483+ recycleData [ 'safe-zone-recycler' ] [ 'efficiency' ] = null ;
484+ recycleData [ 'safe-zone-recycler' ] [ 'yield' ] = [ ] ;
485+
486+ const rows = data . matchAll ( RUSTLABS_ITEM_RECYCLE_ROW_REGEX ) ;
487+ for ( const row of rows ) {
488+ if ( row . length !== 2 ) exit ( ) ;
489+ const rowData = row [ 0 ] ;
477490
478- const shortnameSub = match [ 1 ] ;
479- const nameSub = Utils . decodeHtml ( match [ 2 ] ) ;
480- let quantity = match [ 3 ] ;
481- const id = Object . keys ( ITEMS ) . find ( e => ITEMS [ e ] . shortname === shortnameSub && ITEMS [ e ] . name === nameSub ) ;
482- if ( id === undefined ) exit ( ) ;
491+ let recyclerType = null ;
492+ const recyclerMatches = rowData . matchAll ( RUSTLABS_ITEM_RECYCLE_ITEM_REGEX ) ;
493+ for ( const match of recyclerMatches ) {
494+ if ( match . length !== 2 ) exit ( ) ;
495+ recyclerType = match [ 1 ] ;
496+ break ;
497+ }
498+ if ( recyclerType === null ) exit ( ) ;
483499
484- let probability = 1 ;
485- if ( quantity === '' ) {
486- quantity = 1 ;
500+ let efficiency = null ;
501+ const efficiencyMatches = rowData . matchAll ( RUSTLABS_ITEM_RECYCLE_ITEM_EFFICIENCY_REGEX ) ;
502+ for ( const match of efficiencyMatches ) {
503+ if ( match . length !== 2 ) exit ( ) ;
504+ efficiency = match [ 1 ] ;
505+ break ;
487506 }
488- else {
489- quantity = quantity . replace ( '×' , '' ) . replace ( / , / g, '' ) ;
507+ recycleData [ recyclerType ] [ 'efficiency' ] = efficiency ;
508+
509+ const matches = rowData . matchAll ( RUSTLABS_ITEM_RECYCLE_OUTPUT_ITEMS_REGEX ) ;
510+ for ( const match of matches ) {
511+ if ( match . length !== 4 ) exit ( ) ;
512+
513+ const shortnameSub = match [ 1 ] ;
514+ const nameSub = Utils . decodeHtml ( match [ 2 ] ) ;
515+ let quantity = match [ 3 ] ;
516+ const id = Object . keys ( ITEMS ) . find ( e => ITEMS [ e ] . shortname === shortnameSub && ITEMS [ e ] . name === nameSub ) ;
517+ if ( id === undefined ) exit ( ) ;
490518
491- if ( quantity . includes ( '%' ) ) {
492- probability = `0. ${ quantity . replace ( '%' , '' ) } ` ;
519+ let probability = 1 ;
520+ if ( quantity === '' ) {
493521 quantity = 1 ;
494522 }
495- }
523+ else {
524+ quantity = quantity . replace ( '×' , '' ) . replace ( / , / g, '' ) ;
496525
497- recycleItems . push ( {
498- id : id ,
499- probability : parseFloat ( probability ) ,
500- quantity : parseFloat ( quantity )
501- } ) ;
526+ if ( quantity . includes ( '%' ) ) {
527+ probability = `0.${ quantity . replace ( '%' , '' ) } ` ;
528+ quantity = 1 ;
529+ }
530+ }
531+
532+ recycleData [ recyclerType ] [ 'yield' ] . push ( {
533+ id : id ,
534+ probability : parseFloat ( probability ) ,
535+ quantity : parseFloat ( quantity )
536+ } ) ;
537+ }
502538 }
503539
504- rustlabsRecycleData [ itemId ] = recycleItems ;
540+ rustlabsRecycleData [ itemId ] = recycleData ;
505541}
506542
507543function processItemDurability ( rustlabsName , shortname , name , data , type = 'items' ) {
@@ -606,14 +642,14 @@ function processItemDurability(rustlabsName, shortname, name, data, type = 'item
606642 }
607643 }
608644 if ( quantity === null ) exit ( ) ;
645+
609646 let quantityTypeId = null ;
610647 if ( quantityTypeShortname !== null && quantityTypeName !== null ) {
611648 quantityTypeId = Object . keys ( ITEMS ) . find ( e =>
612649 ITEMS [ e ] . shortname === quantityTypeShortname && ITEMS [ e ] . name === quantityTypeName ) ;
613650 if ( ! quantityTypeId ) exit ( ) ;
614651 }
615652
616-
617653 /* Time */
618654 let timeString = null , time = null ;
619655 const timeMatches = [ ...dataMatch . matchAll ( RUSTLABS_ITEM_DURABILITY_TIME_REGEX ) ] ;
0 commit comments