Improvements with Steam.

This commit is contained in:
Storm Dragon
2026-04-07 19:03:46 -04:00
parent 633ff214a4
commit 2d9790de88
2 changed files with 149 additions and 0 deletions
@@ -44,6 +44,8 @@ class Utilities(ChromiumUtilities):
def clearSteamVirtualizedListCaches(self) -> None:
self.clearContentCache()
self._steamInferredButtonLabels = {}
self._isUselessImage = {}
self._shouldFilter = {}
def isSteamVirtualizedList(self, obj) -> bool:
if not (obj and self.inDocumentContent(obj)):
@@ -76,6 +78,21 @@ class Utilities(ChromiumUtilities):
cache[obj] = inferredLabel
return inferredLabel
def isUselessImage(self, obj) -> bool:
if not (obj and self.inDocumentContent(obj)):
return super().isUselessImage(obj)
cached = self._isUselessImage.get(hash(obj))
if cached is not None:
return cached
rv = super().isUselessImage(obj)
if not rv:
rv = self._isRedundantSteamImage(obj)
self._isUselessImage[hash(obj)] = rv
return rv
def _shouldInferSteamButtonLabel(self, obj) -> bool:
if not (obj and self.inDocumentContent(obj)):
return False
@@ -113,6 +130,34 @@ class Utilities(ChromiumUtilities):
return "Add Friend"
return ""
def _isRedundantSteamImage(self, obj) -> bool:
if not AXUtilities.is_image_or_canvas(obj):
return False
if AXObject.get_name(obj) or AXObject.get_description(obj):
return False
if AXObject.get_child_count(obj):
return False
if AXUtilities.is_focusable(obj):
return False
if not AXObject.has_action(obj, "click-ancestor"):
return False
roleDescription = self._normalizeSteamLabelText(AXObject.get_role_description(obj) or "")
if roleDescription and roleDescription.casefold() not in ["unlabeled image", "image"]:
return False
nearbyLabel = self._getSteamNearbyImageLabel(obj)
if not self._isUsefulSteamLabel(nearbyLabel):
return False
tokens = ["STEAM: Treating redundant image as useless:", obj, "(label:", nearbyLabel, ")"]
debug.printTokens(debug.LEVEL_INFO, tokens, True)
return True
def _getSteamNearbyButtonLabel(self, obj) -> str:
parent = AXObject.get_parent(obj)
if parent is None:
@@ -132,6 +177,25 @@ class Utilities(ChromiumUtilities):
return self._getSteamLabelFromChildren(grandParent, ignore=parent)
def _getSteamNearbyImageLabel(self, obj) -> str:
parent = AXObject.get_parent(obj)
if parent is None:
return ""
siblingLabel = self._getSteamLabelFromChildren(parent, ignore=obj)
if siblingLabel:
return siblingLabel
parentLabel = self._getSteamReadableText(parent)
if self._isUsefulSteamLabel(parentLabel):
return parentLabel
grandParent = AXObject.get_parent(parent)
if grandParent is None:
return ""
return self._getSteamLabelFromChildren(grandParent, ignore=parent)
def _getSteamLabelFromChildren(self, obj, ignore=None) -> str:
for child in AXObject.iter_children(obj):
if child == ignore: