Repository: WishMelz/imgur
Branch: main
Commit: bf99ecf5e499
Files: 2
Total size: 12.3 KB
Directory structure:
gitextract_wjgt27xx/
├── README.md
└── index.html
================================================
FILE CONTENTS
================================================
================================================
FILE: README.md
================================================
# imgur
基于 **imgur** 的web图片托管页面,即开即用

## 配置 `ClientID`
在 `https://api.imgur.com/oauth2/addclient` 注册 `clientId`

```
const res = await fetch('https://api.imgur.com/3/upload', {
method: 'POST',
headers: { Authorization: `Client-ID ${clientId}` },
body: formData,
})
```
================================================
FILE: index.html
================================================
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>imgur</title>
<meta name="description" content="基于imgur的web图片托管页面">
<meta name="keywords"
content="imgur,图床,免费图床,在线图床,图片托管,免费图片存储,图片上传网站,图片分享平台,图片存储服务,图片云存储,图片外链,快速图片上传,匿名图床服务,图片托管网站,图片存储工具,图片上传和存储服务,图片托管">
</head>
<style>
body,
html {
margin: 0;
padding: 0;
}
.forkicon {
position: fixed;
top: 0px;
right: 0px;
border: 0px;
width: 150px;
user-select: none;
}
.main {
padding-top: 60px;
min-height: 100vh;
box-sizing: border-box;
font-family: Avenir, Helvetica, Arial, sans-serif;
}
.upload-demo {
text-align: center;
}
.upload-demo .info {
display: inline-block;
text-align: center;
cursor: pointer;
outline: 0;
}
.upload {
background-color: #fff;
border: 1px dashed #d9d9d9;
border-radius: 6px;
box-sizing: border-box;
width: 360px;
height: 180px;
text-align: center;
position: relative;
overflow: hidden;
}
.upload.highlight {
background-color: rgba(32, 159, 255, .06);
border: 2px dashed #409eff;
}
.upload:hover {
border-color: #409eff;
}
.upinp {
display: none;
}
.upload-info .text {
color: #606266;
font-size: 14px;
text-align: center;
}
.upload-info .text em {
color: #409eff;
font-style: normal;
}
.upload-info .icon svg {
color: #c0c4cc;
margin: 40px 0 16px;
line-height: 50px;
}
.line {
display: block;
height: 1px;
width: 100%;
margin: 24px 0;
background-color: #dcdfe6;
position: relative;
}
.res-info {
text-align: center;
}
.res-link {
font-size: 20px;
padding-bottom: 20px
}
.footer {
position: fixed;
bottom: 0;
left: 0;
right: 0;
text-align: center;
color: #c0c4cc;
font-size: 16px;
}
.footer span {
cursor: pointer;
}
.loading {
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
background: #1413136b;
display: grid;
place-items: center;
display: none;
}
.loading svg {
width: 30px;
animation: rotateAnimation 2s infinite linear;
}
@keyframes rotateAnimation {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
</style>
<body>
<a target="_blank" href="https://github.com/WishMelz/imgur">
<img class="forkicon"
src="https://cdn.jsdelivr.net/gh/WishMelz/file@master/messy/614b81962449bb3430193bdd6eaa3c7f.png" alt="">
</a>
<div class="main">
<div class="footer">
<span><a style="color:#606266;" href="https://github.com/WishMelz/imgur">基于 imgur 的web程序</a></span>
<!-- <span>|</span>
<span>历史记录</span> -->
</div>
<div class="upload-demo">
<div class="info">
<div class="upload">
<div class="upload-info">
<div class="icon">
<svg t="1692252618256" viewBox="0 0 1024 1024" version="1.1"
xmlns="http://www.w3.org/2000/svg" p-id="18739" width="60" height="60">
<path
d="M768.114773 384c0-140.8-115.2-256-256-256S256.114773 243.2 256.114773 384c-145.066667 0-260.266667 119.466667-256 264.533333 4.266667 140.8 128 247.466667 268.8 247.466667H384.114773c25.6 0 42.666667-17.066667 42.666667-42.666667v-128H375.58144c-38.4 0-55.466667-46.933333-29.866667-72.533333l136.533334-136.533333c17.066667-17.066667 42.666667-17.066667 59.733333 0l136.533333 136.533333c25.6 25.6 8.533333 72.533333-29.866666 72.533333H597.448107v128c0 25.6 17.066667 42.666667 42.666666 42.666667h115.2c140.8 0 264.533333-106.666667 264.533334-247.466667 8.533333-145.066667-106.666667-264.533333-251.733334-264.533333z"
p-id="18740" fill="#c0c4cc"></path>
</svg>
</div>
<div class="text">将文件拖到此处,或 <em>点击上传</em> </div>
<div class="text"><b>支持 ctrl + v 上传</b></div>
</div>
<input type="file" class="upinp" name="file" multiple>
</div>
</div>
</div>
<div class="line"></div>
<div class="resmain">
<div class="res-info">
<div class="res-link">
<b id="resurl">https://i.imgur.com/nGI3Js1.png</b>
</div>
<div class="res-img">
<img id="resimg" src="https://i.imgur.com/nGI3Js1.png" alt="">
</div>
</div>
</div>
</div>
<div class="loading">
<div class="info">
<svg t="1692859661070" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4043" width="128" height="128"><path d="M511.882596 287.998081h-0.361244a31.998984 31.998984 0 0 1-31.659415-31.977309v-0.361244c0-0.104761 0.115598-11.722364 0.115598-63.658399V96.000564a31.998984 31.998984 0 1 1 64.001581 0V192.001129c0 52.586273-0.111986 63.88237-0.119211 64.337537a32.002596 32.002596 0 0 1-31.977309 31.659415zM511.998194 959.99842a31.998984 31.998984 0 0 1-31.998984-31.998984v-96.379871c0-51.610915-0.111986-63.174332-0.115598-63.286318s0-0.242033 0-0.361243a31.998984 31.998984 0 0 1 63.997968-0.314283c0 0.455167 0.11921 11.711527 0.11921 64.034093v96.307622a31.998984 31.998984 0 0 1-32.002596 31.998984zM330.899406 363.021212a31.897836 31.897836 0 0 1-22.866739-9.612699c-0.075861-0.075861-8.207461-8.370021-44.931515-45.094076L195.198137 240.429485a31.998984 31.998984 0 0 1 45.256635-45.253022L308.336112 263.057803c37.182834 37.182834 45.090463 45.253022 45.41197 45.578141A31.998984 31.998984 0 0 1 330.899406 363.021212zM806.137421 838.11473a31.901448 31.901448 0 0 1-22.628318-9.374279L715.624151 760.859111c-36.724054-36.724054-45.018214-44.859267-45.097687-44.93874a31.998984 31.998984 0 0 1 44.77618-45.729864c0.32512 0.317895 8.395308 8.229136 45.578142 45.411969l67.88134 67.88134a31.998984 31.998984 0 0 1-22.624705 54.630914zM224.000113 838.11473a31.901448 31.901448 0 0 0 22.628317-9.374279l67.88134-67.88134c36.724054-36.724054 45.021826-44.859267 45.097688-44.93874a31.998984 31.998984 0 0 0-44.776181-45.729864c-0.32512 0.317895-8.395308 8.229136-45.578142 45.411969l-67.88134 67.884953a31.998984 31.998984 0 0 0 22.628318 54.627301zM255.948523 544.058589h-0.361244c-0.104761 0-11.722364-0.115598-63.658399-0.115598H95.942765a31.998984 31.998984 0 1 1 0-64.00158h95.996952c52.586273 0 63.88237 0.111986 64.337538 0.11921a31.998984 31.998984 0 0 1 31.659414 31.97731v0.361244a32.002596 32.002596 0 0 1-31.988146 31.659414zM767.939492 544.058589a32.002596 32.002596 0 0 1-31.995372-31.666639v-0.361244a31.998984 31.998984 0 0 1 31.659415-31.970085c0.455167 0 11.754876-0.11921 64.34115-0.11921h96.000564a31.998984 31.998984 0 0 1 0 64.00158H831.944685c-51.936034 0-63.553638 0.111986-63.665624 0.115598h-0.335957zM692.999446 363.0176a31.998984 31.998984 0 0 1-22.863126-54.381656c0.317895-0.32512 8.229136-8.395308 45.41197-45.578141l67.88134-67.884953A31.998984 31.998984 0 1 1 828.693489 240.429485l-67.892177 67.88134c-31.020013 31.023625-41.644196 41.759794-44.241539 44.393262l-0.697201 0.722488a31.908673 31.908673 0 0 1-22.863126 9.591025z" fill="#ffffff" p-id="4044"></path></svg>
</div>
</div>
</body>
<script>
/**
* imgur 上传图片的 clientId
* 注册应用:https://api.imgur.com/oauth2/addclient
* 查看已注册:https://imgur.com/account/settings/apps
*/
const clientId = 'b2e5734394755e0'
let uploadInp = document.querySelector('.upinp')
let dropzone = document.querySelector('.upload')
let loadingDom = document.querySelector('.loading')
// 阻止默认的拖放行为
dropzone.addEventListener('dragover', function (e) {
e.preventDefault()
dropzone.classList.add('highlight')
})
// 拖放结束时移除高亮样式
dropzone.addEventListener('dragleave', function (e) {
dropzone.classList.remove('highlight')
})
// 处理拖放事件
dropzone.addEventListener('drop', function (e) {
e.preventDefault()
dropzone.classList.remove('highlight')
var files = e.dataTransfer.files
handleImage(files)
})
uploadInp.addEventListener('change', function (e) {
var file = e.target.files
handleImage(file)
})
document.querySelector('.upload').onclick = function () {
uploadInp.click()
}
async function handleImage(file) {
let fileOne = file[0]
const formData = new FormData()
formData.append('image', fileOne)
loadingDom.style.display = 'grid'
const res = await fetch('https://api.imgur.com/3/upload', {
method: 'POST',
headers: { Authorization: `Client-ID ${clientId}` },
body: formData,
})
loadingDom.style.display = 'none'
if (res.ok) {
const resData = await res.json()
if (resData.success) {
setHistory(resData.data.link)
}
}
}
function setHistory(url) {
document.querySelector('#resurl').innerHTML = url
document.querySelector('#resimg').src = url
let urlList = localStorage.getItem('historyList')
if (urlList) {
urlList = JSON.parse(urlList)
} else {
urlList = []
}
urlList.push({
url,
timer: Date.now()
})
localStorage.setItem('historyList', JSON.stringify(urlList))
}
document.addEventListener("paste", function (event) {
var isChrome = false
if (event.clipboardData || event.originalEvent) {
//某些chrome版本使用的是event.originalEvent
var clipboardData =
event.clipboardData || event.originalEvent.clipboardData
if (clipboardData.items) {
// for chrome
var items = clipboardData.items,
len = items.length,
blob = null
isChrome = true
for (var i = 0; i < len; i++) {
if (items[i].type.indexOf("image") !== -1) {
//getAsFile() 此方法只是living standard firefox ie11 并不支持
blob = items[i].getAsFile()
}
}
if (blob !== null) {
var reader = new FileReader()
reader.readAsDataURL(blob)
//base64码显示
reader.onload = function (event) {
// event.target.result 即为图片的Base64编码字符串
var base64_str = event.target.result
let blob = dataURLtoBlob(base64_str)
let file = blobToFile(blob, Date.now() + ".png")
handleImage([file])
}
}
}
}
})
function dataURLtoBlob(dataurl) {
var arr = dataurl.split(","),
mime = arr[0].match(/:(.*?);/)[1],
bstr = atob(arr[1]),
n = bstr.length,
u8arr = new Uint8Array(n)
while (n--) {
u8arr[n] = bstr.charCodeAt(n)
}
return new Blob([u8arr], { type: mime })
}
function blobToFile(theBlob, fileName) {
theBlob.lastModifiedDate = new Date() // 文件最后的修改日期
theBlob.name = fileName // 文件名
return new File([theBlob], fileName, {
type: theBlob.type,
lastModified: Date.now(),
})
}
</script>
</html>
gitextract_wjgt27xx/ ├── README.md └── index.html
Condensed preview — 2 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (14K chars).
[
{
"path": "README.md",
"chars": 355,
"preview": "# imgur\n基于 **imgur** 的web图片托管页面,即开即用\n\n\n\n## 配置 `ClientID`\n在 `https://api.imgur.com"
},
{
"path": "index.html",
"chars": 12236,
"preview": "<!DOCTYPE html>\n<html lang=\"en\">\n\n<head>\n <meta charset=\"UTF-8\">\n <meta http-equiv=\"X-UA-Compatible\" content=\"IE=e"
}
]
About this extraction
This page contains the full source code of the WishMelz/imgur GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 2 files (12.3 KB), approximately 4.2k tokens. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.