I am making an chrome extension that shares url to one website. Now I need a code that can get current URL navigated in browser. When I click on icon I want to open new tab (http://www.thatsite.com/sharer.php?u= + current URL
).
I have two files:
manifest.json
{
"name": "Share on that site",
"version": "1",
"browser_action": {
"default_icon": "icon.png"
},
"background": {
"scripts": ["background.js"]
},
"permissions": ["tabs"],
"manifest_version": 2
}
and background.js
chrome.browserAction.onClicked.addListener(function(activeTab){
var newURL = "http://www.leegly.com/sharer.php?u=" + <current URL here>;
chrome.tabs.create({ url: newURL });
});