|
本帖最后由 minick 于 2023-8-17 20:39 编辑
e4j的帖子https://hostloc.me/thread-1197264-1-1.html
现在上传限制境外ip了
体验:https://pdsimg.131213.xyz/
部署
复制 代码 里的代码粘贴到 Worker 中并部署
[ol]async function getSign() {
const url = "http://www.pdsycj.cn/serveapi/xlt/get/get/STS";
const data = {
signature: "complaint"
};
const headers = {
'Accept': 'application/json, text/plain, */*',
'Accept-Encoding': 'gzip, deflate',
'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8',
'Connection': 'keep-alive',
'Content-Type': 'application/json',
'Host': 'www.pdsycj.cn',
'Origin': 'http://www.pdsycj.cn',
'Referer': 'http://www.pdsycj.cn/complaintInfo?value=%E5%A4%9A%E7%BA%A7%E5%88%86%E9%94%80',
'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1'
};
try {
const response = await fetch(url, {
method: 'POST',
headers: headers,
body: JSON.stringify(data)
});
if (!response.ok) {
throw new Error('Network response was not ok');
}
const result = await response.json();
return result;
} catch (error) {
console.error('Error:', error);
}
}
addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request))
})
async function handleRequest(request) {
const url = new URL(request.url);
const clientIP = request.headers.get("CF-Connecting-IP")
if (url.pathname == "/") {
const html = await fetch("https://raw.githubusercontent.com/x-dr/cf_pages/main/pdsycj.html")
const page =await html.text()
return new Response(page, {
headers: {
"content-type": "text/html;charset=UTF-8",
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Credentials": "true",
"Access-Control-Allow-Headers": "*",
"Access-Control-Allow-Methods": "*",
"ip": `Access cloudflare's ip:${clientIP}`
},
})
} else if (url.pathname == "/getsign") {
const clientIP = request.headers.get("x-forwarded-for") || request.headers.get("clientIP")
const data = await getSign();
const json = JSON.stringify(data);
return new Response(json, {
headers: {
"content-type": "application/json;charset=UTF-8",
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Credentials": "true",
"Access-Control-Allow-Headers": "*",
"Access-Control-Allow-Methods": "*",
"ip": `Access cloudflare's ip:${clientIP}`
},
})
}
}[/ol]复制代码 |
|