How to grab the html of a div that the user hover on

54 views
Skip to first unread message

aziz boudi

unread,
Jan 20, 2021, 6:30:51 AMJan 20
to Chromium Extensions
I'm trying to grab the html of the div that the user hover on, can this be done using the method chrome.pageCapture.saveAsMHTML? or are there other methods that allow me to do that ?

Thanks in advance

guest271314

unread,
Jan 20, 2021, 10:17:30 AMJan 20
to Chromium Extensions, aziz....@gmail.com
You can get outerHTML of the element on hover. You can also copy the outerHTML to clipboard and prompt to save using File System Access API.

Simeon Vincent

unread,
Jan 22, 2021, 5:53:38 PMJan 22
to Chromium Extensions, guest...@gmail.com, aziz....@gmail.com
Ah, but how do you determine which element to get the outer HTML of? Aziz, you might want to checkout Stack Overflow. This answer in particular seems pretty solid to me.

Also, to answer your question about saveAsMHTML; no, that's now what that method does. It saves the entire page, not a subset of the DOM tree.

Cheers,

Simeon - @dotproto
Chrome Extensions DevRel
Reply all
Reply to author
Forward
0 new messages