git clone https://github.com/motao123/lsky-api-chrome.git
# 或直接下载 zip 解压到任意目录
https://cnb.cool/code_free/lsky-api-chrome
chrome://extensions。lsky-api-chrome。清单文件与权限参考:[/manifest.json]
- Manifest Version: 3
- 权限:storage、unlimitedStorage
- host_permissions:
https://*/*、http://*/*- 扩展页面:action popup、options 页面
Accept: application/json在“图床设置”页面中进行如下配置(参考代码位置:[/options.html]、[/js/options.js]):
https://img.imotao.comBearer 1|xxxx... 中的令牌部分(填写时无需带 Bearer 前缀)url | markdown | html | bbcode | thumbnailstrategy_id 传入点击“测试连接”按钮,会进行以下校验:
GET {domain}/api/v1/profile(校验令牌与权限)OPTIONS/GET {domain}/api/v1/upload(校验接口可用性与限流状态){domain}/api/v1Authorization: Bearer <token>Accept: application/jsonX-RateLimit-Limit、X-RateLimit-Remaining401/403/429/500参考接口文档:https://img.imotao.com/page/api-docs.html
弹窗核心上传逻辑参考:[/js/popup.js]:
const formData = new FormData();
formData.append('file', file);
if (strategyId) formData.append('strategy_id', strategyId);
const controller = new AbortController();
const timer = setTimeout(() => controller.abort(), requestTimeoutMs);
const resp = await fetch(`${domain}/api/v1/upload`, {
method: 'POST',
headers: {
Authorization: 'Bearer ' + apiToken,
Accept: 'application/json',
},
body: formData,
signal: controller.signal
});
clearTimeout(timer);