In my chrome extension, I wanted to get the user given URL of the new chrome tab. The targeted page is a SAML based authentication page, which redirects and end up at idp page.
I started with simple approaches like:
document.referrer
which has given last referer, but not the initial url , which user entered in the URL bar.
2nd Approach:
chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) {
console.log(changeInfo.url);
});
But for any TabStatus
it doen't return the exact url which I expected.
Example:
- put this above code to a background script or enter it on the background console.
- open a new incognito window/tab and enter https://mail.google.com/mail/u/0/#inbox
console output:
chrome://newtab/
https://www.google.com/intl/si/gmail/about/#
2nd url is the landed page's URL but not the url I entered.
My next plan is to try chrome.webRequest.onBeforeRequest
which seems complex, but before that, I wanted to know whether is there any easy way to get this?