Skip to content

Prevent target="_blank" #810

Closed Answered by ValeryVerkhoturov
ValeryVerkhoturov asked this question in Q&A
Discussion options

You must be logged in to vote

I solved it with injector

const observer = new MutationObserver(() => {
  removeTargetBlank();
});

function removeTargetBlank() {
  document.querySelectorAll('a[target="_blank"]').forEach(link => {
    link.removeAttribute('target');
  });
}

const config = {
  childList: true,
  subtree: true
};

observer.observe(document.body, config);

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by ValeryVerkhoturov
Comment options

You must be logged in to vote
2 replies
@artibix
Comment options

@ValeryVerkhoturov
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants