XFoxPrower Author

How do Greasemonkey and Tampermonkey compare? I've only used Greasemonkey on Firefox and Tampermonkey on Chrome. But they both exist on Firefox and there's like no sources on which has the best performance / features or the history between them.



Without writing it for you, here's a general approach to it:

  1. Identify all tags on the page
document.getElementsByTagName('a'));
  1. Loop through the collection of tags.
  2. Set the target attribute on each to force them to open in a new tab. A keyword of '_blank' will ensure a new tab each time the link is clicked. Or a unique identifier (such as the video's ID from the url) will ensure clicking the same link multiple times will only create / overwrite it's specified named tab.
  3. (Advanced): Everything above will only work for things on the page at the time the script runs and not on newly fetched content (such as clicking 'Load More' on a playlist). For that, you'll need to watch the parent container for newly added content ('Mutations') and call your function on that new content. One way is with the MutationObserver