Chrome.History get link url (js)

I would like to write a chrome extension that not only displays the URLs that have been visited in History, but also the URLs of links. For example, if I clicked on Wikipedia from Google, it should say: "Wikipedia: link to Google."

My initial attempt was to take the HistoryItem for the URL in question, extract its last VisitItem file, and then use referringVisitId to track the starting URL, however this is where I got stuck. My problem comes down to understanding the meaning of referingVisitId. Is this the identifier of the story item that opened the new page? Is the VisitItem object identifier a triggered URL? The documentation states that this is a “referrer visit identifier”, however it still leaves me puzzled.

1) What is the meaning of referringVisitId?

2) Can I use referringVisitId to track the link URL? If so, how?

Thank you for your time!

+6
source share
1 answer
  • referringVisitId is represented by the VistItem identifier that led to the current VisitItem element.

  • It seems that it is not possible to request for VisitItem using only its ID. Or try to get the HistoryItem to which VisitItem belongs.

The next best thing would be to try using onCreated and onUpdated to try and track the last tab the user was in.

This also has drawbacks, although if a new tab is opened using window.open while you are on another tab, you will get the wrong referrer. If you did not try to intercept all calls on window.open .

TL DR: It’s not easy to get a tab by opening the current tab.

+1
source

Source: https://habr.com/ru/post/948247/


All Articles