I made an extension with popup window and one button. When this button clicked, extension open all links on the page with class '.link' a new tab. But when I clicked nothing works :( How to link 2 scripts?
popup.js
document.addEventListener('DOMContentLoaded', function() {
let openScreensBtn = document.getElementById('btnScreens');
openScreensBtn.addEventListener('click', function() {
let links = document.querySelectorAll('.link');
let arrLinks = Array.from(links);
let arrHref = [];
for (let i = 0; i < arrLinks.length; i++) {
arrHref.push(arrLinks[i].getAttribute('href'));
};
for (let i = 0; i < arrHref.length; i++) {
window.open(arrHref[i], '_blank');
};
});
});
popup.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Index</title>
<script src="popup.js"></script>
</head>
<body>
<button id="btnScreens">Open Screens</button>
</body>
</html>
manifest.json
{
"name": "Ext",
"description" : "",
"version": "1.0",
"manifest_version": 2,
"browser_action": {
"default_icon": "128.png",
"default_popup": "popup.html"
},
"permissions": [
"activeTab"
]
}