I would like to write a chrome extension which not only lists the URLs visited in the History, but the referring URLs as well. For example, if I clicked on Wikipedia from Google, it should say "Wikipedia: referred to by Google".
My initial attempt was to take a HistoryItem for the URL in question, extract its most recent VisitItem, and then use referringVisitId to track down the initial URL, however this is where I got stuck. My problem comes down to not understanding the meaning of referringVisitId. Is it the ID of the history item which opened the new page? Is it the ID of the VisitItem initiated by the URL click? The documentation states that it is the "visit ID of the referrer", however this still leaves me puzzled.
1) What is the meaning of referringVisitId?
2) Can I use referringVisitId to track down the referring URL? If so, how?
Thank you for your time!
referringVisitId
seems to be the ID of the VistItem which led to the current VisitItem.
It looks like it isn't possible to query for a VisitItem using only it's ID. Or try to get the HistoryItem that the VisitItem belongs to.
The next best thing would be to try using the onCreated and onUpdated event together to try to track the last tab the user was in.
This also has it's flaws though, if a new tab is opened using window.open
while you are in another tab, you would get the wrong referrer. Unless you tried to intercept all calls to window.open
.
TL;DR: It's not easy to get the tab that opened the current tab.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With