I am creating a google chrome extension and I need to create a popup modal. I don't want to use the default popup that chrome has to offer, because the size and function is very limited. I want to create my own modal that pops up when the user clicks on the browser extension icon. I have tried what feels like everything.
Here is my current setup with my manifest, html, and scripts:
manifest.json
{
"name": My Extension",
"version": "1.0",
"permissions":
["activeTab", "declarativeContent", "storage", "tabs", "http://*/*", "https://*/*"],
"options_page": "options.html",
"background": {
"scripts": ["background.js"],
"persistent": false
},
"browser_action": {
"scripts": ["js/script.js"],
"default_icon": {
"16": "images/S_pink_background.png",
"32": "images/S_pink_background.png",
"48": "images/S_pink_background.png",
"128": "images/S_pink_background.png"
}
},
"icons": {
"16": "images/S_pink_background.png",
"32": "images/S_pink_background.png",
"48": "images/S_pink_background.png",
"128": "images/S_pink_background.png"
},
"manifest_version": 2
}
modal.html
<div id="myModal" class="modal">
<div class="modal-content">
<span class="close">×</span>
<p>Some text in the Modal..</p>
</div>
</div>
script.js
var modal = document.getElementById("myModal");
var span = document.getElementsByClassName("close")[0];
chrome.browserAction.onClicked.addListener(
modal.style.display = "block";
)
span.onclick = function() {
modal.style.display = "none";
}
window.onclick = function(event) {
if (event.target == modal) {
modal.style.display = "none";
}
}
This modal is obviously just a simple modal. css is in my html file.
Any help is greatly appreciated!
EDITED/UPDATED POST
With no solution found for creating a different custom modal on browser icon click, I have decided to use the default chrome popup with a button in the popup, that will open up my custom modal. I have had a little bit of success, but I can't get the modal to open up on the browser tab/window. The modal opens up in the chrome extension popup box.
Here is what the popup looks like before and after I try to open my custom modal.