Rudokhvist / ASF-STM

ASF bot list trade matcher
Apache License 2.0
24 stars 2 forks source link

Fix cards missing error when card name is different between badge page and trade offer page #19

Closed ngoclong19 closed 1 year ago

ngoclong19 commented 1 year ago

There are cases where the error "cards missing" is incorrectly reported.

Let's consider this check: https://github.com/Rudokhvist/ASF-STM/blob/1fe1a276c30931bd0a9871b34d6f6c0d095b8063/ASF-STM.user.js#L1638

The card "Soldiers" has different name in badge page and trade offer/market listing page. In badge page, it is "Soldiers": https://steamcommunity.com/my/gamecards/368770 In trade offer/market listing page, it is "Soldiers (Trading Card)", the "Trading Card" part is localizable, follows user's Steam language setting: https://steamcommunity.com/market/listings/753/368770-Soldiers (Trading Card) The check elem.name === inv[item].name will fail.

In badge page, the card image source is: https://community.cloudflare.steamstatic.com/economy/image/IzMF03bk9WpSBq-S-ekoE33L-iLqGFHVaU25ZzQNQcXdA3g5gMEPvUZZEfSMJ6dESN8p_2SVTY7V2NoJzHQLmChCIzb02CleauloMc7U00PyrOOKGSmhO2CQKnTYTgk_H7pePGGM_jql7LvAQzDLQO0tFggCeqQH-mxLOJ_bIUh9g5FZpHe8klZCFxspdcAbI1m5ky1EMrwmkXJFfZkEnXX5IJzRggw2bxdpXbGyUrSWboiswS4lCQQnQfcMIoaXmwJLvOk In trade offer/market listing page, the card image source is: https://community.cloudflare.steamstatic.com/economy/image/IzMF03bk9WpSBq-S-ekoE33L-iLqGFHVaU25ZzQNQcXdA3g5gMEPvUZZEfSfIKVcT80svHaAG4bBlYBbyXAKkDkBemTs1GBhYLhfN8fCyQDpsqSEEXXwbWqSfHaNGQtpT7RZZ2HZ9zrw5eSUS26dQOAuQgwFKKMC9WJKNcGLOkRvyt1LrCO6mFZ5GwQXe8hHdwrmmSIRaORyyyARfJhVkSamIsXQg1dqbxU-XenkUbWXa4nxkSYtDBtmS75aOtyD_ijuDxRWYOY The check inv[item].icon_url.endsWith(elem.hash) will also fail.

A test trade offer URL: https://steamcommunity.com/tradeoffer/new/?partner=130444359&token=lvQ2oje0&source=asfstm&them=irV5Q.552990-Roma&you=JLvOk.368770-Soldiers It should alert "Not 1:1 trade", instead of "Cards missing".


In this PR, I would like to add the following changes:

Tested in Firefox 116, and Tampermonkey 4.19.

Rudokhvist commented 1 year ago

Sorry for slow response, I don't have much time for development recently, and I needed to check a few things in regards to this issue. So, that's what I have to say about it:

ngoclong19 commented 1 year ago

Thank you for your response and detail analysis!

Now it is clear to me that card images could be localized. With this new information at hand, I think this PR is irrelevance.

About the type annotation. In the past, I have had issue due to dynamic typing, which caused unintended effect. So with type annotation, I hope that static code analysis tools, TypeScript in this case, could catch the problem, and help to verify that what code I write is what I want.

I will close this pull request.

Rudokhvist commented 1 year ago

About the type annotation. In the past, I have had issue due to dynamic typing, which caused unintended effect. So with type annotation, I hope that static code analysis tools, TypeScript in this case, could catch the problem, and help to verify that what code I write is what I want.

Idea is nice, but thing is - I don't use typescript, so it will be just an additional burden in the code for end users. I wonder if it's also can be automated with github actions too - then it would actually make sense to add those declarations.

Rudokhvist commented 6 months ago

Hi, I've fount a workaround for the issue you've tried to address in this PR. If you are interested in helping and have cards to match - you may test new version too https://github.com/Rudokhvist/ASF-STM/pull/25 Any feedback is welcome!

ngoclong19 commented 6 months ago

Thank you! I'll try it out when I have more duplicate cards available.