Reputation: 241
I have the following code to detect the url from the browser tab. I want to detect the protocol of that url (is it http or https). How can I do this?
chrome.tabs.query({currentWindow: true, active: true}, function(tabs){
console.log(tabs[0].url);// returning the current url of tab
});
Upvotes: 1
Views: 601
Reputation: 9794
You could simply split the url on ":"
// protocol will be http or https
var protocol = tabs[0].url.split(":")[0];
Upvotes: 1