I'm trying to write a simple Chrome extension to grab info on flats from a website but I can't even get the on/click functions from JQuery to work.
manifest.json
{
"manifest_version": 2,
"name": "Flat",
"description": "Adds flats to app",
"version": "1.0",
"browser_action": {
"default_icon": "icon.png",
"default_popup": "popup.html"
},
"permissions": [
"activeTab",
],
"content_scripts": [
{
"matches": [
"https://www.spareroom.co.uk/flatshare/flatshare_detail.pl*",
],
"js": ["lib/jquery.min.js", "lib/bootstrap.min.js", "content.js"]
}
]
}
content.js
$(document).ready(function () {
console.log('Viewing flat');
$("#hello").on("click", function () {
console.log("Hello");
});
$("#hello").click(function () {
console.log("hello");
});
});
popup.html
<html>
<head>
<title>Popup</title>
<link rel="stylesheet" href="lib/bootstrap.min.css">
<link rel="stylesheet" href="style.css">
<script src="lib/jquery.min.js"></script>
<script src="lib/bootstrap.min.js"></script>
<script src="content.js"></script>
</head>
<body>
<div class="container">
<button id="hello" class="btn btn-default">Add Flat</button>
</div>
</body>
</html>
I'm not sure what the issue here is. JQuery is 3.2.1 and Bootstrap is 3.3.7. There is not a lot of JQuery related Chrome Extensions questions on here. I found this one Chrome extensions with jQuery but I already have the document ready function encapsulating the other code. Also looked at this one $(document).click() not working in chrome extension but that solution doesn't take advantage of JQuery click/on functions.