diff --git a/src/main.js b/src/main.js
index 9e50cec..ddd7e8d 100644
--- a/src/main.js
+++ b/src/main.js
@@ -4,9 +4,14 @@ import { currentAttribute } from './dom.js';
import { startRequestInterceptor } from './interceptor.js';
function findAnchorElement() {
- // Try several selectors in priority order. Torn's gym page structure
- // varies; we cast a wide net and return the first match.
+ // Try several selectors in priority order. Torn's gym page renders the
+ // training UI as
(the list of attribute
+ // rows). Anchor the dialog above that list.
const candidates = [
+ 'ul[class*="properties"]',
+ '[class*="gymContent"]',
+ '[class*="gymContentWrapper"]',
+ // Legacy fallbacks (kept in case Torn ever wraps the list in a form):
'form[action*="train"]',
'form.train-form',
'form[class*="train"]',
@@ -18,18 +23,7 @@ function findAnchorElement() {
];
for (const sel of candidates) {
const el = document.querySelector(sel);
- if (el) {
- // Prefer the form ancestor if the match is a button/link, since we
- // want to anchor above the whole form, not just the button.
- return el.closest('form') || el;
- }
- }
- // Last-ditch: any element inside the gym panel that looks like the
- // training form.
- const panel = document.querySelector('.gym, #gym, [class*="gym-"], [class*="Gym"]');
- if (panel) {
- const form = panel.querySelector('form');
- if (form) return form;
+ if (el) return el;
}
return null;
}