0

I’m not knowledgeable in JavaScript. In fact, the code I pasted here is actually someone else’s of which was revised by a contributor. Here is the link: Get all links with contain a word

See I have this email I sent to myself containing my logged history of Firefox of certain year, and I want to extract only the URL links containing the word "rule34" from it.

So I was searching on Google of "how to copy each link that contains a specific word" and the first search result was that link.

Here is the code that was written by temerariomalaga of which the version I pasted on here was revised by idmean.

I do not know how to indent four spaces of the code, so I just took a screenshot

So I copied and pasted this revised script of temerariomalaga into the JavaScript console of Chrome on the page of my Gmail Firefox histories, and I replaced the example URL "http://www.example.es" with my link to my email of my histories.

And I replaced the example word "apple" with rule34.

But when I clicked Enter, all I got was this:

VM179:3 Uncaught SyntaxError: Unexpected token '>'

Did it not work because while this is a URL link it's not actually one of a website or is there something else I did wrong?

This is what I exactly pasted into the console.

Again, I do not know how to indent four spaces, so this is screenshot of what I pasted in chrome console.

This is the page where I opened inspect element selected console and pasted the JavaScript code by temerariomalaga of revised by idmean.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
  • 1
    Don't use screenshots for text. Read: https://stackoverflow.com/help/how-to-ask – Orifjon Sep 01 '23 at 00:43
  • 1
    First, that code of yours is in PHP, not JS. Browser consoles won't even run it. Second, please [don't post images of code/error/textual content](https://meta.stackoverflow.com/q/285551). Copy and then paste them here as text. – InSync Sep 01 '23 at 01:20
  • Re *"I do not know how to indent four spaces of the code"*: One way is to select the lines and press the `{}` icon (fifth icon from the right. Hover text *"Code Sample
     Ctrl + K"*). Or press `Ctrl` + `K` (with text selected). In most text editors, selecting the code and pressing Tab will also work.
    – Peter Mortensen Sep 01 '23 at 10:00
  • 80% of questions on Stack Overflow don't receive answers (in a timely fashion). You are competing against questioners who put more effort into their questions. – Peter Mortensen Sep 01 '23 at 10:12
  • Related (but is not about off-topic installation help questions): *[What should a 'minimal, reproducible example' include for problems with automating web browsers using Selenium?](https://meta.stackoverflow.com/questions/405791/what-should-a-minimal-reproducible-example-include-for-problems-with-automati)*. It [includes](https://meta.stackoverflow.com/questions/405791/what-should-a-minimal-reproducible-example-include-for-problems-with-automati/405792#405792) *"Examples of Good Questions"* – Peter Mortensen Sep 01 '23 at 10:45

0 Answers0