mirror of
https://github.com/fireinrain/JHS-enhance.git
synced 2026-09-28 07:36:38 +08:00
Merge pull request #2 from anupamme/fix-repo-jhs-enhance-remove-hardcoded-imgur-client-id
fix: the userscript embeds imgur api credentials dir... in...
This commit is contained in:
Vendored
+8
-1
@@ -10809,10 +10809,17 @@ ${err.stack}` : "");
|
||||
type: mimeType
|
||||
}), formData = new FormData();
|
||||
formData.append("image", blob);
|
||||
const idKey = "jhs_imgurClientId";
|
||||
let clientId = localStorage.getItem(idKey);
|
||||
if (!clientId) {
|
||||
clientId = window.prompt("请输入您自己的Imgur Client-ID(可前往 https://api.imgur.com/oauth2/addclient 免费申请)用于图片上传搜索:");
|
||||
if (!clientId) throw new Error("未提供Imgur Client-ID,无法上传图片");
|
||||
localStorage.setItem(idKey, clientId);
|
||||
}
|
||||
const response = await fetch("https://api.imgur.com/3/image", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: "Client-ID d70305e7c3ac5c6"
|
||||
Authorization: `Client-ID ${clientId}`
|
||||
},
|
||||
body: formData
|
||||
}), data = await response.json();
|
||||
|
||||
@@ -162,10 +162,17 @@ class ImageRecognitionPlugin extends BasePlugin {
|
||||
type: mimeType
|
||||
}), formData = new FormData;
|
||||
formData.append("image", blob);
|
||||
const idKey = "jhs_imgurClientId";
|
||||
let clientId = localStorage.getItem(idKey);
|
||||
if (!clientId) {
|
||||
clientId = window.prompt("请输入您自己的Imgur Client-ID(可前往 https://api.imgur.com/oauth2/addclient 免费申请)用于图片上传搜索:");
|
||||
if (!clientId) throw new Error("未提供Imgur Client-ID,无法上传图片");
|
||||
localStorage.setItem(idKey, clientId);
|
||||
}
|
||||
const response = await fetch("https://api.imgur.com/3/image", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: "Client-ID d70305e7c3ac5c6"
|
||||
Authorization: `Client-ID ${clientId}`
|
||||
},
|
||||
body: formData
|
||||
}), data = await response.json();
|
||||
|
||||
Reference in New Issue
Block a user