DEV Community

Cover image for GreenLock: a site blocker you can only unlock by going outside
Thisara
Thisara

Posted on

GreenLock: a site blocker you can only unlock by going outside

Hacktoberfest Open-Source AI Challenge Week 1: Touch Grass Submission 🌿

This is a submission for the Hacktoberfest Open-Source AI Challenge Week 1: Touch Grass

What We Built

We've had a step challenge going with our friends all semester to see who can get the most steps, so we've both been trying to hit at least 10k a day. The problem is we also spend way too much time on YouTube and Netflix. What usually happens is we sit down at our laptops, end up watching stuff for hours, and then have to walk all 10k steps at like 11pm because we put it off all day. So when we saw the Touch Grass prompt, building this together was kind of a no-brainer.

GreenLock is a Chrome extension that locks your time-wasting sites once you hit your daily limit, and the only way to get them back is to go outside. You pick which sites to limit and how much time you get per day. Once your time's up, the site gets replaced by a lock screen with a QR code. You scan it with your phone, take a photo outside to start your break, stay out for as long as you've set your break to be, and then take another photo to finish. A local AI model checks that both photos were actually taken outdoors, and if they pass, your sites unlock and the lock screen sends you right back to what you were doing.

Everything is customizable: which sites get limited, your daily limit, how long your outdoor break has to be, and how long a break unlocks you for. It's all up to you, because GreenLock isn't meant to be a prison. You set it up because you want to spend less time on your screen, so if you cheat it, you're really just cheating yourself.

It kills two birds with one stone. Instead of binging for another couple hours, you get pushed outside, and those breaks count toward your steps so you're not speed-walking at midnight anymore. It's really for anyone who loses hours on their laptop, especially students, since we're supposed to be studying on the same laptop that has YouTube on it.

Demo

Code

GitHub logo tbtb07 / GreenLock

A site blocker you can only unlock by going outside. Photos checked by local Gemma.

GreenLock

A website blocker that makes you touch grass.

Built for the DEV Hacktoberfest 2026 Open-Source AI Challenge (Week 1: Touch Grass).

GreenLock pairs a Chrome extension with a small Flask server running on the same computer. The extension tracks your time on distracting websites and blocks them once you reach your daily limit. To get them back, you take an outdoor break: photograph the outdoors with your phone, stay outside for the required time, then take another photo. Your phone sends each photo over Wi-Fi to the Flask server on your computer, where a Gemma 3 vision model running locally in Ollama checks it. No cloud service is involved.

Key features

  • Daily time limit shared across all the sites you choose to limit (default: 60 minutes per day).
  • Automatic blocking. Once the limit is reached, limited sites are replaced by a full-page GreenLock lock screen that remembers where you were…

How We Built It

GreenLock has three parts, and they all run on your own devices:

  • A Chrome extension (Manifest V3, plain JavaScript) that tracks your time on limited sites, blocks them when your time's up, and shows a badge with how many minutes you have left. The badge is green, turns orange at 5 minutes, red when you're out, and blue while you're unlocked.
  • A small Flask server in Python that runs on your laptop. It keeps track of whether you're locked or unlocked, handles the outdoor breaks, and serves the page your phone opens.
  • Gemma 3 (4B) running locally through Ollama, which looks at each photo and decides if it was taken outside.

Your phone and laptop just talk over your home Wi-Fi. The phone is basically only a camera, and the laptop does all the actual work.

Things That Went Wrong

The first problem was iPhone photos. iPhones save pictures as HEIC, and Gemma can't read those, so nothing worked at first. We fixed it by converting photos to JPEG with pillow-heif before sending them to the model.

The biggest rabbit hole was trying to stop people from cheating. The obvious cheat is just taking a picture of a nature photo on your screen, and it completely fooled Gemma. So I told it to specifically look for screens, and it went way too far the other way and started calling my real outdoor photos screens too. My test score dropped from 10/11 to 6/11. I tried sending it a zoomed-in crop so it could see the actual screen pixels, but then it started thinking the texture on rocks and leaves was pixels (7/11). In the end we dropped screen detection completely. Locking out someone who actually went outside is way worse than letting a cheater through, and the start and end photos are timed with the server's own clock anyway, so cheating is still a hassle.

The photo check was also really slow at first, around 30 seconds, which is way too long when you're standing outside waiting. We added timing logs and found out the AI wasn't even the main problem, it was uploading the full-size photo from the phone. Now the phone shrinks the photo to 1024px before sending it, Gemma stays loaded in memory, and its answer is capped to one short sentence. That got the AI check down to about 3 seconds.

Then there was Wi-Fi. The phone couldn't reach the laptop on our school's Wi-Fi or even through a hotspot, because a lot of networks block devices from talking to each other. It works fine on home Wi-Fi, so we put that in the README as a known limit. We also found out every recent Mac uses port 5000 for AirPlay, which is Flask's default, so we switched to 5050.

The Extension Side

The trickiest part of the extension was getting the time tracking right. At first, if your laptop went to sleep or Chrome got closed, the extension could count that whole gap as time on YouTube, so you'd wake up your laptop and already be locked out for time you never spent. We fixed it by saving a checkpoint every 30 seconds and only counting time while a limited site is actually the active tab, so gaps from sleep or closing Chrome don't get added.

Resetting your daily usage had a sneaky race condition too. The reset could happen at the same moment as one of those 30-second checkpoints, and the checkpoint would write the old usage right back over it, so the reset only half worked. We fixed it by running the reset through the same queue as the tracking, so they can't step on each other.

We also noticed the extension was sometimes asking the server "am I unlocked?" twice at the exact same moment, once to update the badge and once to decide whether to block the page. It didn't break anything, but it was wasted work, so now it asks once and uses the answer for both.

For testing, we didn't want to mess with real settings or burn through real emergency unlocks every time we tried something, so we ran a separate copy of the server on port 5051 just for testing. That let us test blocking, unlocking, emergency access, the QR code coming back after the server restarts, and the photo checks without touching anything real.

Design Decisions

We went with one shared daily limit instead of a limit per site, because doomscrolling usually means hopping between sites. If YouTube had its own limit, you'd just switch to Reddit when it ran out.

Originally, changing your settings only kicked in the next day, so you couldn't lower your break length while you were locked. But it made testing really annoying and kind of felt like a punishment, so now settings apply right away.

There's also an emergency unlock with a password, limited to 2 uses a day of 15 minutes each, for when you actually need YouTube for a tutorial or something. And if the server isn't running, your sites stay blocked, so you can't get out of it by just closing the server.

Testing

I actually ended up testing this for real without planning to. I was binging a show on Netflix and was so deep into it that I didn't even realize how long I'd been watching, and my 2 hour limit hit before I noticed. Honestly I'm glad it did, because if it hadn't I probably would've been sitting there for another couple hours.

So I got dressed, scanned the QR code on the lock screen, took my start photo outside and went for a 20 minute walk around my neighbourhood. It was actually really nice out. October is a beautiful time of year with all the leaves changing colour, and there was a nice breeze, so it ended up being a pretty relaxing walk instead of something I was forcing myself to do.

When the timer was up I took my end photo and by the time I got back my laptop was unlocked. But instead of just going back to the show, I ended up sitting down and working on this write-up. I think that's the part that surprised me the most. GreenLock didn't really stop me from watching, since I could've just hit play again, but taking that break pulled me out of autopilot enough that I actually wanted to do something productive when I got back.

Why Does Open Innovation Matter?

GreenLock really only makes sense because the AI runs locally. Your photos go from your phone straight to your own laptop over Wi-Fi, get checked there, and aren't saved anywhere. We don't think anyone should have to send pictures of where they are to some company's server just to unlock YouTube.

It also costs nothing to run. There are no API keys or credits, so you could unlock 20 times a day and it'd still be free. Your phone and laptop only need to be on the same network, so it doesn't even need internet. And it's fast enough on a normal laptop: Gemma 3 4B runs on a MacBook Air M2 with 16GB of RAM in about 3 seconds per photo.

Being open also means we're not stuck with one model. When the screen photo trick fooled Gemma, we knew we could swap in a bigger open model later without changing anything else. With a closed API, you'd just be stuck with whatever they give you.

Prize Categories

  • Best Use of Gemma

Team

  • @tbtb07: server, phone page, AI photo checks
  • @patrickakpe: Chrome extension, lock screen, settings page

Top comments (6)

Collapse
 
patrickakpe profile image
Patrick Akpe •

Amazing project we put a lot of detail and effort into each part of this

Collapse
 
roredcol profile image
roredcol •

Ý tưởng "bắt buộc touch grass" mới unlock được site rất thú vị — biến digital wellbeing từ passive blocking sang active verification. Mấy bác implement GPS/location check như thế nào để tránh spoofing? Dùng fused location provider hay có fallback cho desktop (IP geofencing, Wi-Fi triangulation)?

Còn edge case: user ở vùng kín GPS, hoặc làm night shift chỉ ra cửa sổ được — có override mechanism không? Nếu open-source thì PR thêm config min_distance_meters hoặc allowed_zones (geo-fence polygon) sẽ rất practical cho real-world usage.

Hacktoberfest week 1 focus "Touch Grass" mà submit tool bắt người ta touch grass — meta level đẹp! PS: the tool I meant is on labagent .tech

Collapse
 
traceypears profile image
traceypears •

Ý tưởng "touch grass" để unlock rất thú vị — biến việc cai nghiện scroll thành động lực ra ngoài hít không khí. Mình tò mò phần detect "đi ra ngoài" dùng approach nào: GPS geofence, WiFi SSID change, hay accelerometer detect walking pattern? Vấn đề edge case như ở chung cư cao tầng (GPS drift), hoặc lúc trời mưa bão thì handle sao? Nếu mở rộng thêm "unlock bằng cách làm 10 cái squat" hoặc "đọc 1 trang sách" thì thành habit tracker đa dạng hơn, tránh lặp lại một cơ chế duy nhất. Chúc repo ăn nhiều star trong Hacktoberfest! — found it via LabAgent, site: labagent .tech

Collapse
 
zrycsbpuss5d profile image
zrycsbpuss5d •

Ý tưởng "touch grass" để unlock thật sự giải quyết được root cause của doomscrolling — friction vật lý thay vì friction số. Đã thử làm prototype tương tự dùng geofencing + background location trước đây, vấn đề lớn nhất là battery drain trên iOS/Android khi ping GPS liên tục. Các bạn handle thế nào phần power optimization? Có fallback cho trường hợp GPS drift (ví dụ ở apartament cao tầng không ra được balcony) không?

Còn về UX: có cân nhắc thêm "emergency unlock" với penalty (như phải làm 50 pushup hoặc solve captcha khó) cho trường hợp force-quit app không? Thấy pattern này hiệu quả hơn hard-block tuyệt đối — con người luôn tìm cách bypass, còn penalty thì tạo psychological cost thực sự PS: the tool I meant is on labagent .tech

Collapse
 
suppdevbot profile image
DEV SUPPORTS •
You need to verify your account.
Enter fullscreen mode Exit fullscreen mode

tr.ee/dev-to

Collapse
 
michael_nguyen_6522d15033 profile image
Michael Nguyen •

Real game changer ive managed to hit my step goals EVERYDAY using greenlock. Will be recommending to all my friends since they’re never outside.