I'm currently trying to develop a web extension that opens links from a particular site in a new window
Here is my code:
var links = document.getElementsByTagName("a");
// get links that redirect to medium.com
function getMediumLinks() {
var mediumLinks = [];
for (var i = 0; i < links.length; i++) {
if (links[i].href.indexOf("medium.com") > -1) {
mediumLinks.push(links[i]);
}
}
return mediumLinks;
}
getMediumLinks().forEach(function(link) {
link.addEventListener("click", function() {
browser.windows.create({
url: link.href,
type: "popup",
width: 800,
height: 600,
incognito: true
});
});
});
But this doesn't seem to happen. Any help is appreciated!.