Trying to AppleScript the Nu HTML checker

Hello,

I've been struggling to write an AppleScript to simplify the process of 
checking whatever web page I'm developing, while previewing it in 
Firefox on a Mac, using the W3C Nu HTML Checker. I can't just feed the 
checker my page's URL, for two reasons: (1) it's on my private 
development server, not public, so my development URL isn't accessible 
to the validator; and (2) my page contains JS and PHP components that 
don't make sense to the validator until Firefox (and my local Apache 
server) has parsed and rendered the page into standard HTML.

Right now I'm loading my page into Firefox, doing Command-U for it to 
show me its rendered code in another tag, doing Command-A Command-C to 
copy all the code to the Mac's clipboard, opening a new tab with the Nu 
HTML Checker pre-set to its text-entry option using 
"https://validator.w3.org/nu/#textarea", clicking on the text-entry box, 
select-all then delete to get rid of what's automatically in there (why 
is there anything in there???), pasting in my code, then telling it to 
check. That's a lot of steps!

I've made some progress AppleScripting this to make it faster/ less 
tedious, but have run into a snag: how to make AppleScript select the 
text entry box once the validator tab opens. I can't even reliably do 
this by scripting "tab" keypresses, because I've discovered something 
totally weird about the Nu HTML validator: regardless of whether I open 
that web page manually or with AppleScript, the text entry box is 
_sometimes_ pre-selected and sometimes not!  Typically it's selected 
_every other time_ I open that page. Huh? I kid you not! I've tried 
clearing the Firefox cache, using a new window instead of a tab, etc.; 
nothing works reliably. I have no idea why the page form is behaving so 
erratically.

Is there some other URL (perhaps a target in the existing URL other than 
just "#textarea"?) that will always pre-select the text entry box? Can 
you give me a clue as to why the page is behaving this way?

Thanks much,
Lawrence

-- 
Lawrence_San_email_signature
Lawrence San
Email: san@sanstudio.com
Graphic Stories, Illustrations, Sketchbook: sanstudio.com 
<https://sanstudio.com/>
Writings, both humorous & serious: santhology.com <https://santhology.com/>

Received on Monday, 18 December 2023 09:16:24 UTC