Big tech has invested billions into creating distractions, so I fought back with my own Chrome extension.
Published: 2025-09-03
URL: https://wonderingaboutai.substack.com/p/how-i-built-a-chrome-extension-to
This is the very first Wondering About AI community post. 🎉 It was contributed by Sachin Agrawal, co-founder of JobTracker. He writes the newsletter AI Lab Notes, which is filled with helpful tips for using AI in your everyday workflows. I find myself scrolling a lot. I have no hard deadlines, as I have recently taken the glamorous route of unemployment to becoming my own boss. There are times when hours pass, and the only thing I have proven is that the endless scroll can really be endless. I decided to build a Chrome extension to help me focus better.
It’s called “2 mins only” and you can find it on GitHub. This post is not about how to improve your focus or why my extension is different from hundreds of other productivity-related extensions on the Chrome marketplace. Rather, it’s about how I approached the process, as someone who was building a Chrome extension for the first time.
What was I trying to build exactly? My goal was to block certain websites where I find myself endlessly scrolling. For me, this is YouTube, YouTube Shorts, LinkedIn, and Reddit. Sometimes I start on a website with every intention of getting work done.
For example, I go to Reddit to get a piece of information. But then I just start scrolling and lose my flow. So, what I wanted to build looks something like this: Before starting your first project, it helps to understand how Chrome extensions work. If you’re building with a new technology, having the basic vocabulary typically used to talk about it improves your prompts and helps you interact with the AI faster and better. It’s similar to how a non-technical team lead should at least know the correct terminology for communicating with the technical members of his team.
At the end of the day, you want to be the one in control, and not the AI. How Chrome extensions work Chrome extensions are mini-programs you can use to customize your browser and web pages experience in countless ways. They are built using familiar web technologies: HTML, CSS, and JavaScript.
Each extension revolves around a manifest file that outlines its metadata and permissions. The manifest acts as the blueprint, telling Chrome how the extension should behave and what resources it uses.
Most extensions have three main parts: Background scripts Background scripts are like invisible helpers that run quietly in the background. They don’t interact with web pages directly but keep track of things and react when something happens in the browser.
For example, a background script can keep a list of all open tabs, so if a tab is closed, it automatically saves a note about it. Content scripts Content scripts work with the actual web pages shown in your browser. They can read information from the page, change how it looks, or add new features.
For example, a content script could find all the email addresses on a page and highlight them. Popup or UI pages Popup or UI pages are the small windows that appear when you click the extension’s icon in the browser toolbar.
This is where you see buttons, forms, or information and can interact with the extension. Developers can also take advantage of Chrome’s extension APIs for advanced possibilities like creating notifications, storing data, or working directly with browser bookmarks and history.
With these building blocks in place, you can modify how web pages look when they are loaded, manage tabs, interact with individual webpages, and configure various settings through a popup. Actually building the extension I used Cursor to build the extension because I like the UI.
But you can also use Claude Code or another AI-enabled coding environment if you prefer. In my experience, Claude 4 Opus and Sonnet are far better than every other LLM when it comes to coding tasks. GPT-5 comes close, though. If you want some tips on how to make the most out of using Cursor, you can check out this post. It’s still missing some details on using MCPs in Cursor, but we do not need that for our task currently.
The first version of “2 mins only” was built with just one prompt. It got me 80% of the way to the final product. The prompt I used was: I want to build a Chrome extension called "2 mins only". If the user goes to a distracting website, it should start a timer for x mins. If after x mins, the user is still on the site then the tab should redirect to a page asking the user to get some work done. There should also be a textbox where the user can enter their goals.
The list of sites is configurable, and x can be different per site. Once the focus screen is activated for a certain site, if the user tries to revisit that site within a configurable cooldown period, the user should be shown the focus site again for a cooldown period.
The cooldown period is configurable. The focus site should contain a timer showing the remaining cooldown time and a textbox asking the user to enter his goals for the remainder of the cooldown period. Treat YouTube and YouTube Shorts separately.
On YouTube, specific channels and videos can be whitelisted, i.e time spent on these videos does not count towards the timer.I just put this into Cursor and Claude 4 did its magic. This prompt worked remarkably well.
It filled in a lot of gaps, and added things which I thought were quite awesome. This was the page it would redirect to if I was on a site like YouTube for too long: I didn’t ask it to write down productivity tips or what kind of UI it should use.
But it just figured those things out. Another fun thing I did as a follow-up prompt was: Can you create an SVG icon and place it in the SVG folder? That was what it came up with: Honestly, LLMs are getting great at drawing logos through SVGs. SVGs are technically text, but render as images, so this hack enables me to do simple logo generation without going through an image generation algorithm. Plus, it also built a UI popup to customize which sites to block and after how long: Testing the extension Once you have an extension ready, you’ll want to zip it and load load into Chrome for testing.
You can do this by: Going to chrome://extensions Turning developer mode on Unzipping your extension Click the "Load unpacked" button Choosing the folder containing your unzipped files For the purposes of this article, I asked Cursor to give me the five most important test cases, so you can get an idea of what kinds of things you may want to test: 1) Timer starts on monitored site Steps: Open https://www.youtube.com/ Expect: Badge shows 1; popup shows active timer with remaining time. 2) Timer expiry → blocked page → cooldown enforcement → auto-return Steps: Let the timer expire while still on the site; during cooldown, try visiting again; wait until countdown ends.
Expect: Redirect to blocked.html with countdown; re-visits redirect to blocked page; auto-redirect back to original URL when countdown completes. 3) Rule specificity for Shorts vs YouTube Steps: Visit https://www.youtube.com/shorts/..., then a normal watch URL in the same tab before expiry. Expect: Shorts rule (more restrictive) applies on Shorts; switching to non-Shorts stops the Shorts-triggered closure on expiry. 4) Learning mode bypass Steps: Enable Learning Mode in popup; visit a monitored site.
Expect: No timer starts; previously blocked site is accessible while learning mode is active. 5) Browser restart lifecycle Steps: With an active timer and at least one site in cooldown, quit and restart Chrome. Expect: Active timers cleared and badge empty; cooldown sites remain blocked until their expiry time. If you find any bugs or unexpected behavior, you can prompt Cursor to fix them.
For example, I discovered that when the cooldown period expires, the blocked site automatically reloads in the background tab. This creates an annoying surprise. Imagine YouTube suddenly blasting audio after a 60-minute cooldown while you're focused on something else.
A quick prompt to Cursor fixed this by keeping the focus page active until I manually choose to return to the site. Conclusion The feeling I get from using something I built is special. It's almost like getting a dopamine rush every time my software stops me from scrolling. I have been using the extension for a week now, and yes the interruptions are sometimes annoying.
But knowing that I built the tool and why I built the tool makes up for the annoyance. Using your own software means that: Your software is built 💯% to suit your needs. You are in control of the direction you take the product in. You feel a dopamine rush every time it works. It's a great time to be building.