20240327-1424

This commit is contained in:
BlueSkyXN 2024-03-27 14:24:59 +08:00
parent 45f6939475
commit e461703f73
5 changed files with 97 additions and 24 deletions

View File

@ -2,15 +2,22 @@ const fs = require('fs');
const path = require('path');
// 设置源文件和目标文件的路径
const srcPath = path.join(__dirname, '..', '..', 'cloudflare-page', 'OneAPI-imgbed-MIX.html');
const destDir = path.join(__dirname, '..', '..', 'dist');
const destPath = path.join(destDir, 'index.html');
const srcDir = path.join(__dirname, '..', '..', 'cloudflare-page'); // cloudflare-page 目录的路径
const srcFilePath = path.join(srcDir, 'Tools-TGPH.html'); // 源文件路径
const destDir = path.join(__dirname, '..', '..', 'dist'); // 目标 dist 目录的路径
const destToolsDir = path.join(destDir, 'tools'); // 目标 tools 目录的路径
const destFilePath = path.join(destToolsDir, 'tgph.html'); // 目标文件路径
// 确保目标目录存在
if (!fs.existsSync(destDir)) {
fs.mkdirSync(destDir, { recursive: true });
if (!fs.existsSync(destToolsDir)) {
fs.mkdirSync(destToolsDir, { recursive: true });
}
// 复制并重命名文件
fs.copyFileSync(srcPath, destPath);
console.log('文件已成功复制并重命名到:', destPath);
// 检查源文件是否存在
if (fs.existsSync(srcFilePath)) {
// 复制并重命名文件
fs.copyFileSync(srcFilePath, destFilePath);
console.log(`文件 ${srcFilePath} 已成功复制并重命名到 ${destFilePath}`);
} else {
console.log(`源文件 ${srcFilePath} 不存在。`);
}

View File

@ -0,0 +1,76 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>URL Transformer</title>
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.2/css/bootstrap.min.css">
<style>
.container {
margin-top: 50px;
}
.result-item {
margin-top: 10px;
border: 1px solid #ccc;
padding: 10px;
border-radius: 5px;
background-color: #f9f9f9; /* 轻微调整背景颜色以适应URL列表 */
}
#urlList {
padding: 10px;
border: 1px solid #ccc;
border-radius: 5px;
max-height: 400px; /* 设置最大高度并允许滚动 */
overflow-y: auto;
}
#urlList div {
margin-top: 8px;
}
</style>
</head>
<body>
<div class="container">
<h2>URL Transformer</h2>
<div class="form-group">
<input type="text" class="form-control" id="inputUrl" placeholder="输入原始URL">
</div>
<button class="btn btn-primary" onclick="transformUrl()">转换URL</button>
<div id="urlList" class="result-item mt-3"></div>
</div>
<script>
function transformUrl() {
const originalUrl = document.getElementById('inputUrl').value;
const fileName = originalUrl.match(/\/file\/(.+)$/)[1]; // 提取文件名
const prefixes = [
'https://telegraph.cachefly.net/file/',
'https://i0.wp.com/telegra.ph/file/',
'https://i1.wp.com/telegraph.cachefly.net/file/',
'https://i2.wp.com/im.gurl.eu.org/file/',
'https://i3.wp.com/missuo.ru/file/',
'https://image.baidu.com/search/down?url=https://i3.wp.com/missuo.ru/file/',
'https://images.weserv.nl/?url=https://missuo.ru/file/',
'https://pic1.xuehuaimg.com/proxy/https://i0.wp.com/missuo.ru/file/',
'https://im.gurl.eu.org/file/',
'https://img1.131213.xyz/file/',
'https://missuo.ru/file/'
];
let transformedUrls = prefixes.map(prefix => `${prefix}${fileName}`);
displayUrls(transformedUrls);
}
function displayUrls(urls) {
const urlList = document.getElementById('urlList');
urlList.innerHTML = ''; // 清空之前的结果
urls.forEach(url => {
const element = document.createElement('div');
element.textContent = url;
urlList.appendChild(element);
});
}
</script>
</body>
</html>

View File

@ -1,8 +1,8 @@
addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request));
event.respondWith(handle58imgRequest(event.request));
})
async function handleRequest(request) {
async function handle58imgRequest(request) {
// 确认请求方法为 POST 并且内容类型正确
if (request.method !== 'POST' || !request.headers.get('Content-Type').includes('multipart/form-data')) {
return new Response('Invalid request', { status: 400 });

View File

@ -1,5 +1,5 @@
addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request));
event.respondWith(handleTgphimgRequest(event.request));
})
async function handleRequest(request) {

View File

@ -57,21 +57,11 @@ addEventListener('fetch', event => {
}
}
async function handle58imgRequest(request) {
// 确认请求方法为 POST 并且内容类型正确
if (request.method !== 'POST' || !request.headers.get('Content-Type').includes('multipart/form-data')) {
return new Response('Invalid request', { status: 400 });
}
// 此处省略了58img的处理逻辑直接复制自 API_IMG_58img.js
}
async function handleTgphimgRequest(request) {
// 确认请求方法为 POST 并且内容类型正确
if (request.method !== 'POST' || !request.headers.get('Content-Type').includes('multipart/form-data')) {
return new Response('Invalid request', { status: 400 });
}
// 此处省略了tgphimg的处理逻辑直接复制自 API_IMG_tgphimg.js
}
// 复制自 API_IMG_58img.js 的辅助函数
function bufferToBase64(buf) {