Skip to content

Commit 9030dd3

Browse files
committed
fix: handling unexpected type of Map.prototype.set and get
1 parent e30cf37 commit 9030dd3

File tree

3 files changed

+20
-12
lines changed

3 files changed

+20
-12
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@list-kr/tinyshield",
3-
"version": "1.3.89",
3+
"version": "1.4.0",
44
"description": "",
55
"type": "module",
66
"scripts": {

sources/banner.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// @downloadURL https://cdn.jsdelivr.net/npm/@list-kr/tinyshield@latest/dist/tinyShield.user.js
99
// @license MIT
1010
//
11-
// @version 1.3.89
11+
// @version 1.4.0
1212
// @author PiQuark6046 and contributors
1313
//
1414
// @match *://ygosu.com/*

sources/src/index.ts

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,16 @@ Win.Function.prototype.toString = new Proxy(Win.Function.prototype.toString, {
2222

2323
Win.Map.prototype.get = new Proxy(Win.Map.prototype.get, {
2424
apply(Target: (key: unknown) => unknown, ThisArg: Map<unknown, unknown>, Args: [unknown]) {
25-
let ArgText = OriginalArrayToString.call(Args) as string
26-
for (const Item of ['{"inventoryId":', '({inventoryId:this']) {
27-
if (OriginalStringIncludes.call(ArgText, Item)) {
28-
console.debug('[tinyShield]: Map.prototype.get:', ThisArg, Args)
29-
throw new Error()
25+
try {
26+
let ArgText = OriginalArrayToString.call(Args) as string
27+
for (const Item of ['{"inventoryId":', '({inventoryId:this']) {
28+
if (OriginalStringIncludes.call(ArgText, Item)) {
29+
console.debug('[tinyShield]: Map.prototype.get:', ThisArg, Args)
30+
throw new Error()
31+
}
3032
}
33+
} catch {
34+
console.warn('[tinyShield]: Map.prototype.get:', ThisArg, Args)
3135
}
3236

3337
return Reflect.apply(Target, ThisArg, Args)
@@ -36,12 +40,16 @@ Win.Map.prototype.get = new Proxy(Win.Map.prototype.get, {
3640

3741
Win.Map.prototype.set = new Proxy(Win.Map.prototype.set, {
3842
apply(Target: (key: unknown, value: unknown) => Map<unknown, unknown>, ThisArg: Map<unknown, unknown>, Args: [unknown, unknown]) {
39-
let ArgText = OriginalArrayToString.call(Args) as string
40-
for (const Item of ['inventory_id']) {
41-
if (OriginalStringIncludes.call(ArgText, Item)) {
42-
console.debug('[tinyShield]: Map.prototype.set:', ThisArg, Args)
43-
throw new Error()
43+
try {
44+
let ArgText = OriginalArrayToString.call(Args) as string
45+
for (const Item of ['inventory_id']) {
46+
if (OriginalStringIncludes.call(ArgText, Item)) {
47+
console.debug('[tinyShield]: Map.prototype.set:', ThisArg, Args)
48+
throw new Error()
49+
}
4450
}
51+
} catch {
52+
console.warn('[tinyShield]: Map.prototype.get:', ThisArg, Args)
4553
}
4654

4755
return Reflect.apply(Target, ThisArg, Args)

0 commit comments

Comments
 (0)