@
cha0sCat HI 你的这段代码好像还有些问题, 比如我能访问
byewind.com, 但是
byewind.com/about 这样的子页面直接访问就出问题了.这样应该怎么解决呢?
addEventListener("fetch", event => {
event.respondWith(handleRequest(event.request))
})
async function handleRequest(request) {
// 目标地址
const target_host = "byewind.framer.website";
// 原地址
const original_host_a = "
byewind.com";
const original_host_b = "
www.byewind.com";
const original_host_c = "
byewind.yuansite.workers.dev";
// 替换 2 次以同时兼容 Worker 来源和域名来源
const url = request.url
.replace(original_host_c, target_host)
.replace(original_host_b, target_host)
.replace(original_host_a, target_host);
const originalResponse = await fetch(url);
if (originalResponse.headers.get('Content-Type') === 'text/html') {
const rewritedContent = await originalResponse.text().then(text => {
// 在这插入自定义代码, 用样式去除 body 的滚动条, 隐藏 Framer 的 logo.添加 JS 动效
return text.replace('</body>', '<style type="text/css"> .__framer-badge {pointer-events: auto; display: none !important;} ::-webkit-scrollbar {display: none;} body {scrollbar-width: none; -ms-overflow-style: none; overflow-x: hidden;overflow-y: auto;}</style><script src="
https://cdnjs.cloudflare.com/ajax/libs/three.js/r134/three.min.js"></script><script src="
https://cdn.jsdelivr.net/npm/vanta@latest/dist/vanta.birds.min.js"></script><script>VANTA.BIRDS({el: "#main",mouseControls: true,touchControls: true,gyroControls: false,minHeight: 200.00,minWidth: 200.00,scale: 1.00,scaleMobile: 1.00,backgroundColor: 0x0,color1: 0x521efc,color2: 0x14ffc7,colorMode: "lerp",wingSpan: 40.00,speedLimit: 10.00,separation: 100.00,alignment: 100.00,cohesion: 100.00})</script></body>');
});
return new Response(rewritedContent, originalResponse)
} else {
return originalResponse
}
}