Answer the question
In order to leave comments, you need to log in
How to open Google search results in JS?
Greetings.
Situation. It is necessary to make a bookmark in the browser in such a way that when you click on it, it opens the first 5 results of the Google PS, but I have not encountered this before and managed to do this:
javascript:(
document.querySelectorAll('.g > div > div > a').forEach(link => link.click())
)()
Answer the question
In order to leave comments, you need to log in
Well, they would immediately write in the question about bookmarklets.
detail:
javascript:(
Array.from(document.querySelectorAll('#rso > div:last-child a[data-ved]:not([id])')) // находим подходящие ссылки. Все у которых есть атрибут data-ved и нет id и лежат в последнем диве у элемента с id = rso
.slice(0, 5) // режем до первых 5ти
.forEach(i => window.open(i.href, '_blank')) // Открываем. Нужно будет разрешить открытие всплывающих окон в браузере. Иначе откроет только 1.
)(); void 0;
javascript:(Array.from(document.querySelectorAll('#rso > div:last-child a[data-ved]:not([id])')).slice(0, 5).forEach(i => window.open(i.href, '_blank')))(); void 0;
thanks for the code. modified to unload top urls. I really needed to get them.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question