with the "success" class (just trained).
+ const lis = document.querySelectorAll('ul[class*="properties"] > li[class*="success"]');
+ for (const li of lis) {
+ if (tatExtractAttrFromLi(li)) return li;
}
- let best = null, bestN = -Infinity;
- for (const root of scope) {
- const candidates = root.querySelectorAll('*');
- for (const c of candidates) {
- if (c.children.length > 0) continue;
- const t = (c.textContent || '').trim();
- if (!/^[\d,]+(\.\d+)?$/.test(t)) continue;
- const n = parseNumber(t);
- if (n == null || n < 1) continue;
- if (n > bestN) { best = c; bestN = n; }
+ // Priority 2: the
corresponding to the .gained message's attribute.
+ const gained = document.querySelector('[class*="gained"]');
+ if (gained) {
+ const text = (gained.textContent || '').toLowerCase();
+ for (const attr of TAT_KNOWN_ATTRS) {
+ if (text.indexOf(attr) !== -1) {
+ const li = document.querySelector('ul[class*="properties"] > li[class^="' + attr + '___"]');
+ if (li) return li;
+ }
}
}
- return best;
- }
- function findValueElement() {
- const candidates = document.querySelectorAll('*');
- let best = null, bestN = -Infinity;
- for (const el of candidates) {
- if (el.children.length > 0) continue;
- const t = (el.textContent || '').trim();
- if (!/^[\d,]+(\.\d+)?$/.test(t)) continue;
- const n = parseNumber(t);
- if (n == null || n < 1) continue;
- if (n > bestN) { best = el; bestN = n; }
+ // Priority 3: the first
in the properties list.
+ const all = document.querySelectorAll('ul[class*="properties"] > li');
+ for (const li of all) {
+ if (tatExtractAttrFromLi(li)) return li;
}
- return best;
+ return null;
}
- function findGymName() {
- const panel = document.querySelector('.gym, #gym, [class*="gym-"], [class*="Gym"]');
- const roots = panel ? [panel, document.body] : [document.body];
- const known = ['Total Bastion', 'Frontline Fitness', 'Gym 300', 'Gym 500', "Baldr's Gym", 'Sportscience Laboratory', 'Premier Fitness', 'Chrome Gym', "Mr. Miyagi's", 'Power House'];
- for (const root of roots) {
- const all = root.querySelectorAll('h1, h2, h3, h4, p, span, div, li');
- for (const el of all) {
- if (el.children.length > 0) continue;
- const t = (el.textContent || '').trim();
- for (const name of known) { if (t.includes(name)) return name; }
+ function tatExtractAttrFromLi(li) {
+ const cls = li.className || '';
+ const parts = cls.split(/\s+/);
+ for (const attr of TAT_KNOWN_ATTRS) {
+ const prefix = attr + '___';
+ for (const c of parts) {
+ if (c.indexOf(prefix) === 0) return attr;
}
}
return null;
}
- function parseNumber(text) {
+ function tatExtractValueFromLi(li) {
+ const valueSpan = li.querySelector('[class^="propertyValue"]');
+ if (!valueSpan) return null;
+ return tatParseNumber(valueSpan.textContent);
+ }
+ function tatFindGymName() {
+ // Gym names live in aria-labels of