A
A
Albert2018-11-11 09:37:56
Google
Albert, 2018-11-11 09:37:56

How to remove google images results with javascript?

In Google images, each result is, roughly speaking, a block (element?) of a clickable image and a clickable text link to the site under this image.
With the help of RMB-Inspect (Ctrl + Shift + I in Chrome) we managed to find this "block" - it starts with

<div jscontroller="Q7Rsec" data-ri="0" class="rg_bx rg_di rg_el ivg-i
. then comes some cipher (id?) like
data-ved="0ahUKEwiXts3WzsveAhVBl4sKHVQwBcsQMwhrKAAwAA"
etc.
If you click "Delete element" in the same place in the inspector, then this element will be deleted and the rest of the results-pictures will shift-fit, taking up free space.
  • Can this be done (remove the result) with JavaScript?
  • If so, how can you get the id of that element?

I need to delete results in my browser, for example results with links to images. which have already been viewed. The links themselves are known.
The browser is simple, I use cefpython. js is executed through ExecuteJavascript, for example, to hide the Google logo on the google.com page, you can write like this:
def _OnDomReady(self):
    self.browser.ExecuteJavascript("document.getElementById('lga').style.display = 'none'; ")

It would be great to understand how to do the removal of certain image results in the same vein.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Pavel Kornilov, 2018-11-11
@KorniloFF

Can this be done (remove the result) with JavaScript?
If so, how can you get the id of that element?

1. Yes
2. If the links themselves are known, then find them.
[/* Массив со ссылками */].forEach(function(i) {
  document.querySelector('[href=' + i + ']').remove();
})

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question