IsThereAnyDeal / AugmentedSteam

Augments your Steam Experience
https://augmentedsteam.com
GNU General Public License v3.0
1.38k stars 85 forks source link

[TASK] Reusable solution for marking nodes as "checked" #1646

Open candela97 opened 1 year ago

candela97 commented 1 year ago

Task Description

We often need to mark nodes as "checked" to avoid processing the same node twice in callback features. The way we do it now is add a class name and check for that in each feature, but it gets messy and is not ideal for e.g. the wishlist where there're a handful of features that target the same node one after another. We should figure out a unified solution that can be reused everywhere if possible.

  1. Use a Symbol: These can be set/read via property access and we can export a single symbol and use it everywhere, but are not convenient for debugging.
  2. Use a data- attribute: There is precedent for this in FHideSpamComments. These are similar to class names and are more idiomatic, while retaining the debugging experience.
MxtOUT commented 1 year ago

Using a WeakSet is also possible (idea from SO). With this you keep your processing information entirely on AS' side, avoiding manipulation from Steam's side and cluttering of the DOM. On the negative side, it's another data structure (though not too bad, space is Θ(1) and operations are Θ(n) on average, if using hash tables) and prevents proper debugging. Debugging is always possible though by setting a breakpoint to where the checking happens.

candela97 commented 10 months ago

Another problem with using class names - e.g. in FDLCCheckboxes we use a mutation observer to watch for class attribute changes when users add DLCs to their wishlists via ds dropdowns, but the class name added by highlighting will trigger a useless observer entry.