I am creating an extension that tracks the specific url and displays the date when that url is accessed then saves it into a text file. It works when I just run the page and script but when adding it to chrome it does nothing.
Manifest.json
{
"name": "Login Tracker",
"version": "0.1",
"manifest_version": 2,
"description": "A Chrome Extension that records the time that you log in",
"browser_action": {
"default_icon": "icon.png",
"default_title": "Login Tracker"
},
"permissions": ["tabs",
"background", "browsingData", "contextMenus", "downloads"
],
"background": {
"scripts": ["loginPage.js", "func.js"]
}
}
loginPage.html
<html>
<head>
<script type="text/javascript" src="func.js">
</script>
</head>
<body>
<h1>Login Tracker</h1>
<p id=demo></p>
<button type="button" onclick="myFunction()">Login</button>
</body>
</html>
func.js
function myFunction() {
var d = new Date();
document.getElementById("demo").innerHTML = d;
var textToSave = d;
var hiddenElement = document.createElement('a');
hiddenElement.href = 'data:attachment/text,' +
encodeURI(textToSave);
hiddenElement.target = '_blank';
hiddenElement.download = d;
hiddenElement.click();
}
loginPage.js
chrome.browserAction.onClicked.addListener(function (activeTab) {
var newURL = "loginPage.html";
chrome.tabs.create({
url: newURL
});
});
Any idea why it does not do anything even just displaying the date? Its working when I view it in local but it does not do anything when being added to chrome. Any help will be appreciated.