DEV Community

杨飞叶
杨飞叶

Posted on

A browser extension called "Open New Tab For Developers"

As a developer, I often browse websites like Medium.com and Hacker News, but the links on these sites open in the same tab. After reading an article, I have to navigate back to the main site, which negatively impacts the user experience. Opening links in a new tab would be much better.

Therefore, I created a browser plugin called "Open New Tab."

Why did I have to write a new plugin? Because I searched for and used some existing plugins, but they mostly implemented a general logic. This general logic is simple and indeed works for most websites. However, it is not enough; merely writing general logic does not work for some specific websites. The functionality of this kind of plugin is quite similar to ad-blocking plugins, which need to handle the specific DOM structure of particular websites.

Take Medium, for example. Its <a> tag's href attribute is not a complete URL but a strange path string. The complete URL is actually in the data-href attribute of an ancestor element. So for this site, the better approach is to get the complete URL and then open it in a new tab.

Therefore, the feature of this plugin is that, while it meets the need to open links in new tabs for all regular websites like Google, it also provides special handling for websites that developers frequently visit, such as Medium and Hacker News.

So, a more fitting name for this plugin would actually be: "Open New Tab For Developers."

tutor:https://www.bilibili.com/video/BV1hrpMe4E6x/
GitHub:https://github.com/cunzaizhuyi/open-new-tab-extension

Top comments (0)