probe-images.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334
  1. /**
  2. * probe-images.js — 只 dump 可见 ImageView 的位置与尺寸
  3. *
  4. * 用途:`userListRows`/`profile` 那套锚点只收"有文案或可点"的节点,
  5. * 而**头像节点两样都不占**(无 text、无 desc、不可点),所以看不见它。
  6. * 「无头像」这个过滤项要落地,就得先知道头像在哪 —— 这是给它用的探针。
  7. */
  8. var OUT = "/sdcard/tiktok_app/probe-images.txt";
  9. var lines = [];
  10. var hits = className('android.widget.ImageView').find();
  11. for (var i = 0; i < hits.size(); i += 1) {
  12. var node = hits.get(i);
  13. var visible = false;
  14. try { visible = node.isVisibleToUser() === true; } catch (e) { visible = true; }
  15. if (!visible) { continue; }
  16. var box = node.bounds();
  17. var w = box.right - box.left;
  18. var h = box.bottom - box.top;
  19. if (w < 8 || h < 8) { continue; }
  20. var id = "";
  21. try { id = String(node.id() || ""); } catch (e) { }
  22. lines.push([
  23. "id=" + (id.indexOf("/") >= 0 ? id.split("/").pop() : id),
  24. "desc=" + JSON.stringify(String(node.desc() || "")),
  25. "b=[" + box.left + "," + box.top + "][" + box.right + "," + box.bottom + "]",
  26. "size=" + w + "x" + h,
  27. "clk=" + (node.clickable() === true)
  28. ].join(" "));
  29. }
  30. files.ensureDir("/sdcard/tiktok_app/");
  31. files.write(OUT, "count=" + lines.length + "\n" + lines.join("\n") + "\n");
  32. console.log("images written: " + lines.length);