中文 | English
关键词:网站拦截插件、Chrome 拦截网站、屏蔽网站、BlockSite 替代、专注模式、番茄钟、防沉迷、上网时长限制、离线、隐私
一个完全本地运行的 Chrome 网站拦截插件。不需要账号、不连接任何服务器、不上传任何数据——打开即用,断网也照样拦截。
为什么做这个:BlockSite 每次都要连它的服务器,导致访问某些网站变慢,网络不好时设置页也加载不出来;密码保护、自定义拦截页这些功能还要付费。所以做了一个完全本地的:拦截由浏览器内核直接完成,不经过任何服务器,打开网页不会变慢,所有功能免费。
✨ 本项目通过 Prompt2App 在线生成:一句话描述想要的软件,AI 自动写出完整工程并打包。想要类似的软件?一句话生成一个 →
Generated online with Prompt2App — describe the app you want in one sentence and AI builds it.
| 拦截规则 | 编辑规则 |
|---|---|
![]() |
![]() |
| 拦截页面 | 每日限制 |
![]() |
![]() |
| 统计信息 | |
![]() |
- 拦截规则:按目的整理要拦截的网站,每条规则有自己的时间表(始终 / 指定星期 + 时间段,支持跨夜)
- 填域名:同时拦截所有子域名(
weibo.com也拦m.weibo.com) - 带路径:只拦某个频道,如
youtube.com/shorts - 关键词:不含
.的视为关键词,网址里包含就拦
- 填域名:同时拦截所有子域名(
- 每日限制:给网站设每天可用分钟数,用完自动拦截,零点恢复(只统计浏览器在前台、正在使用的时间;播放声音时也计入)
- 专注计时器:开始后所有启用规则里的网站都被拦截(忽略时间表),可额外指定专注时才拦的网站
- 统计信息:今日/近 7 天拦截次数、各网站使用时长,保留 60 天
- 密码保护:设置页加锁,专注模式只能在设置页提前结束
- 自定义拦截页面:标题、提示语、随机激励语
- 备份与恢复:规则导出为 JSON,换电脑再导入
- 已打开的标签页在规则生效时会被立即拦截
- 下载本仓库(
git clone或 Code → Download ZIP 后解压) - Chrome 打开
chrome://extensions,右上角打开「开发者模式」 - 点「加载已解压的扩展程序」,选择本项目文件夹
- 点工具栏的 LocalBlock 图标即可快速拦截当前网站或开始专注;完整设置在「打开设置」
Edge、Brave 等 Chromium 内核浏览器同样可用。
- 使用 Manifest V3 的
declarativeNetRequest动态规则,由浏览器内核直接把请求重定向到本地拦截页,不依赖后台脚本常驻,也不读取网页内容 - 所有数据保存在
chrome.storage.local - 后台每分钟检查一次时间表和限额,到点自动更新规则
| 权限 | 用途 |
|---|---|
| declarativeNetRequest + 所有网站 | 拦截并重定向到拦截页 |
| tabs | 读取当前标签页网址,用于快速拦截、统计时长、拦截已打开的页面 |
| storage | 本地保存规则和统计 |
| alarms | 每分钟检查时间表/限额,专注结束提醒 |
| idle | 离开电脑时不计入使用时长 |
| notifications | 专注结束通知 |
manifest.json 插件配置
background.js 后台:生成拦截规则、统计时长
common.js 公共逻辑:规则解析、时间表判断
options.* 设置页
popup.* 工具栏弹窗
blocked.* 拦截页
styles.css 设置页/弹窗样式
icons/ 图标
screenshots/ README 截图(不打进下载包)
LocalBlock is a 100% offline, privacy-first website blocker for Chrome / Edge / Brave — a lightweight BlockSite alternative with no account, no server, and no tracking. BlockSite talks to its servers all the time, which slows down some sites, and charges for features like password protection and custom block pages; LocalBlock does all of it locally and for free. Everything lives in chrome.storage.local, and blocking is done natively by Manifest V3 declarativeNetRequest, so it keeps working even without network.
Features
- Block lists with per-rule schedules (days of week + time range, overnight supported); domains (incl. subdomains), paths like
youtube.com/shorts, or URL keywords - Daily time limits per site (auto-block when used up, resets at midnight)
- Focus timer (Pomodoro) that enforces all rules regardless of schedule
- Local statistics: blocked attempts and time spent per site
- Password protection for settings
- Custom block page, JSON backup / restore
Install: open chrome://extensions, enable Developer mode, click Load unpacked, and select this folder.
MIT




