Skip to content

Commit

Permalink
下载图片时带上UA以避免某些API返回异常
Browse files Browse the repository at this point in the history
  • Loading branch information
xh321 committed Mar 23, 2024
1 parent ed680af commit e8e16b5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,12 @@ function isValidUrl(str) {
function request(url) {
return new Promise((resolve, reject) => {
const protocol = url.startsWith("https") ? https : http;
const req = protocol.get(url);
const req = protocol.get(url, {
headers: {
"User-Agent":
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0",
},
});
req.on("error", (error) => reject(error));
req.on("response", (res) => {
// 发生跳转就继续请求
Expand Down
4 changes: 2 additions & 2 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"name": "背景插件",
"slug": "background_plugin",
"description": "在QQNT聊天界面轮播展示背景图,同时让QQNT界面透明化以便更好地展示背景图。",
"version": "0.2.17",
"version": "0.2.18",
"icon": "./icon.png",
"authors": [
{
Expand All @@ -16,7 +16,7 @@
"repo": "xh321/LiteLoaderQQNT-Background-Plugin",
"branch": "master",
"release": {
"tag": "0.2.17",
"tag": "0.2.18",
"file": "Background.zip"
}
},
Expand Down

0 comments on commit e8e16b5

Please sign in to comment.