excuse my noob ness, I've been scouring the net for the past 3 hours trying to find some jumping off points to cobble this together its no avail.
I have an Alfred action that will open the current songs lyric page from genius.com. i'd like to copy the reader view of the site that just shows the lyrics nice and clean, and copying that to a popup window that stays on top from KM.
I realize there are probably many ways to get the result. I've thought of using a bookmarklet that converts the article/lyric to text to display that, i've looked into ways to AppleScript the conversion of the html page to Reader view. Before I continue, I've got all these possible avenues but not sure what's the best way. In my noob mindset, I may be making it more complicated.
I'm not looking for a handout, i won't complain though, and it would be appreciated hopefully it makes sense what i'm trying to do. and would greatly appreciate any guidance/ideas/work arounds, etc.
This attempts to retrieve the page HTML. It uses the page found at /amp/..., as there's a lot less junk to sieve out. The macro uses a regular expression match to isolate the portion of the HTML that contains the song lyrics. This portion is, itself, HTML, so I stuck that into a temporary file and displayed it using a custom HTML prompt, which the AppleScript at the bottom resizes to the full length of the screen, and positions on the left-hand-side of the screen as a floating modal window.
You can see I tried to use some CSS to change the font of the lyrics away from Times New Roman into something sans serif, but that hasn't been successful. I'll let you play around with that and see what you discover.
Thanks for the 2 different approaches. There are some little tweaks I'll make to them but these are spot on. Now to try and get the url from the front most tab and I'm gold, I'll see if I can figure that out.
Hm, that is strange. My relevant stats: System info:AppleScript version:2.7System version:10.13.6Keyboard Maestro version:8.2.4
Perhaps it's best that he sticks to your macro in that case until the problem can be diagnosed (if I can reproduce it, which, currently, I cannot).
Eyeballing it, one thing to try could be to disable the action that deletes the temporary file. It's possible that your system runs faster than mine (a measly MacBook 12"), so deletes the file before it's had a chance to load in the HTML prompt. Just a guess, though.
Do you know if something like that is possible ? I sat around reading Apple's WebKit docs for ages, and came across a lot of very useful-sounding DOM methods, but which are all annoyingly deprecated.
And obviously, we can download the HTML source using an NSURLSession method or something similar, but that wouldn't give us the object model data we'd need in order to navigate it.