I'm trying to make a small chrome extension that will replaces the target in javascript window.open links but not sure how to approach.
this is an example link:
<a href="javascript:void(window.open('https://www.google.com','_blank','toolbar=1,location=1,status=1,menubar=1,scrollbars=1,resizable=1'));">
Here I want to replace '_blank' with '_self' instead so all these links open in the same tab.
Edit: just noticed some of the links has __blank or _new so need to replace other variations.
If you want to do this with all <a> tags, you can use a for loop:
for (let link of document.querySelectorAll("a")) { // Note: for/of was recently introduced
link.href = link.href.replace("_blank", "_self");
};