@@ -5,7 +5,6 @@ declare const unsafeWindow: unsafeWindow
55const Win = typeof unsafeWindow !== 'undefined' ? unsafeWindow : window
66
77const OriginalArrayToString = Win . Array . prototype . toString
8- const OriginalStringIncludes = Win . String . prototype . includes
98
109const ProtectedFunctionStrings = [ 'toString' , 'get' , 'set' ]
1110
@@ -20,24 +19,30 @@ Win.Function.prototype.toString = new Proxy(Win.Function.prototype.toString, {
2019 }
2120} )
2221
22+ const ASInitPositiveRegExps : RegExp [ ] [ ] = [ [
23+ / [ a - z A - Z 0 - 9 ] + * = > * { * c o n s t * [ a - z A - Z 0 - 9 ] + * = * [ a - z A - Z 0 - 9 ] + * ; * i f / ,
24+ / = = = ? * [ a - z A - Z 0 - 9 ] + * \[ * [ a - z A - Z 0 - 9 ] + \( * [ 0 - 9 ] + * \) * \] * \) * r e t u r n * [ a - z A - Z 0 - 9 ] + * \( * { * i n v e n t o r y I d * : / ,
25+ / { * i n v e n t o r y I d * : * t h i s * \[ [ a - z A - Z 0 - 9 ] + * \( * [ 0 - 9 ] + * \) * \] * , * \. \. \. * [ a - z A - Z 0 - 9 ] + * \[ * [ a - z A - Z 0 - 9 ] + * \( * [ 0 - 9 ] + * * \) * \] * } * \) /
26+ ] ]
2327Win . Map . prototype . get = new Proxy ( Win . Map . prototype . get , {
2428 apply ( Target : ( key : unknown ) => unknown , ThisArg : Map < unknown , unknown > , Args : [ unknown ] ) {
25- let ArgText = ''
26- try {
27- ArgText = OriginalArrayToString . call ( Args ) as string
28- } catch {
29- console . warn ( '[tinyShield]: Map.prototype.get:' , ThisArg , Args )
29+ if ( Args . length > 0 && typeof Args [ 0 ] !== 'function' ) {
30+ return Reflect . apply ( Target , ThisArg , Args )
3031 }
31- for ( const Item of [ '{"inventoryId":' , '({inventoryId:this' ] ) {
32- if ( OriginalStringIncludes . call ( ArgText , Item ) ) {
33- console . debug ( '[tinyShield]: Map.prototype.get:' , ThisArg , Args )
34- throw new Error ( )
35- }
32+
33+ let ArgText = OriginalArrayToString . call ( Args ) as string
34+ if ( ASInitPositiveRegExps . filter ( ASInitPositiveRegExp => ASInitPositiveRegExp . filter ( Index => Index . test ( ArgText ) ) . length >= 2 ) . length === 1 ) {
35+ console . debug ( '[tinyShield]: Map.prototype.get:' , ThisArg , Args )
36+ throw new Error ( )
3637 }
38+
3739 return Reflect . apply ( Target , ThisArg , Args )
3840 }
3941} )
4042
43+ const ASReinsertedAdvInvenPositiveRegExps : RegExp [ ] [ ] = [ [
44+ new RegExp ( 'inventory_id,[a-zA-Z0-9-]+\/[a-zA-Z0-9]+\/[a-zA-Z0-9]+' )
45+ ] ]
4146Win . Map . prototype . set = new Proxy ( Win . Map . prototype . set , {
4247 apply ( Target : ( key : unknown , value : unknown ) => Map < unknown , unknown > , ThisArg : Map < unknown , unknown > , Args : [ unknown , unknown ] ) {
4348 let ArgText = ''
@@ -46,11 +51,9 @@ Win.Map.prototype.set = new Proxy(Win.Map.prototype.set, {
4651 } catch {
4752 console . warn ( '[tinyShield]: Map.prototype.get:' , ThisArg , Args )
4853 }
49- for ( const Item of [ 'inventory_id' ] ) {
50- if ( OriginalStringIncludes . call ( ArgText , Item ) ) {
51- console . debug ( '[tinyShield]: Map.prototype.set:' , ThisArg , Args )
52- throw new Error ( )
53- }
54+ if ( ASReinsertedAdvInvenPositiveRegExps . filter ( ASReinsertedAdvInvenPositiveRegExp => ASReinsertedAdvInvenPositiveRegExp . filter ( Index => Index . test ( ArgText ) ) . length >= 1 ) . length === 1 ) {
55+ console . debug ( '[tinyShield]: Map.prototype.set:' , ThisArg , Args )
56+ throw new Error ( )
5457 }
5558
5659 return Reflect . apply ( Target , ThisArg , Args )
0 commit comments