Thanks for this code, which I like very much and have added to my write.as blogs as a security measure.
Recently I had a need to add links in a blog page to other internal parts of the same page. I was confused as to why they were being opened in a new browser page rather than navigating to the specified header staying within the page. Before I realized what caused that issue, I posted a forum message about it here.
Today I remembered I had added this js code to my configuration, which included this line of code which opens all links in a new tab:
post_links[i].target = "_blank";
So I modified the code to execute that line ONLY for links external to write.as/writeas.com. Now links to internal parts of a blog page work stay within the same page, while still having protection when navigating to external sites (which continue to open in a new page with the ‘noreferrer noopener’ security measure).
h = post_links[i].href;
if (!h.includes("write.as") && !h.includes("writeas.com") {
post_links[i].target = "_blank";
}
Again, thanks for your code which is a prudent security measure.