But I can't get it to work. Nothing happens, not even an error. (I had JS errors before in the console - "Allow JavaScript from Apple Events" is activated). I'd appreciate any help. Thank you.
Tried it with a dot right before the selector [document.querySelector('.span.js-buy-config-color-code').innerText;], and now at least I get an error message:
Uncaught TypeError: Cannot read properties of null (reading 'innerText')
at :37:57
at :38:4
Thank you! This is certainly an interesting idea. But does it work just as quickly? This is an action I'd need hundreds of times a day so I'm looking for an efficient way to solve this problem. I'm wondering why my query does not work. I might have an error in the syntax but tried all the examples I could find (with 'value' instead of 'innerText', or even just the trainling dot e.g.).
I'm also thinking about using a command line tool like Cheerio or BeautifulSoup for this. But since the page is already loaded into the browser, I'd prefer to go this way.
Great idea to ask ChatGPT! I often do this for RegEx but it didn't came to my mind in this occasion. It can be really helpful. And what can I say - this is right! document.querySelector('.js-buy-config-color-code').innerText returns the text inside of the element when entered in Chrome Console. And so does 'span.js-buy-config-color-code':
But (a very big BUT): the macro returns nothing! I do explicitely ask for Chromium, but tried that in Safari as well. The result is the same: nothing happens, and I can clearly confirm that by watching the console.
Hah! Of course I didn't check these settings! It is that simple! Now it works - with both, modern and not so modern syntax. I read about the changes concerning the syntax but somehow didn't dive deeper. Thank you all, thank you very much! I think I looked for the Syntax thing in the preferences menu on the right and didn't find it there, and then I quickly forgot about it. But that explains why I stumbled upon a JS error in Chrome, it was complaining about a closing bracket at some point which I didn't write and couldn't explain.
This is a great function. Too bad it doesn't work with Firefox. But that could make things a lot easier for my work, so I'll probably switch browsers for that.