bilibili.com
查看链接
https://www.bilibili.com/video/BV1BQCrYhE4h/?spm_id_from=333.1365.list.card_archive.click&vd_source=b4a9b09ca563034fa8713c991907841e
脚本(源码)👇 也可到网盘下载:https://pan.quark.cn/s/c52106bd4849
javascript
addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request))
});
// 配置区域
const CONFIG = {
upstream: "your_domain", //这里写你的super域名链接
upstreamMobile: "your_domain", //这里写你的super域名链接
customDomain: "your_domain", //这里写你的域名
blockedRegions: ["RU"], //要屏蔽国家
blockedIPs: ["0.0.0.0", "127.0.0.1"]
};
// 主请求处理函数
async function handleRequest(request) {
const url = new URL(request.url);
const { pathname, search } = url;
// 强制HTTPS
if (url.protocol === 'http:') {
url.protocol = 'https:';
return Response.redirect(url.href);
}
// 确定上游域名
const upstreamDomain = await detectDevice(request)
? CONFIG.upstream
: CONFIG.upstreamMobile;
// 构建上游请求
const modifiedRequest = createProxyRequest(request, upstreamDomain);
try {
const response = await fetch(modifiedRequest);
return await processResponse(response, upstreamDomain, url.host);
} catch (error) {
return new Response(`Proxy Error: ${error.message}`, { status: 500 });
}
}
// 创建代理请求
function createProxyRequest(originalRequest, upstreamDomain) {
const url = new URL(originalRequest.url);
url.host = upstreamDomain;
const headers = new Headers(originalRequest.headers);
headers.set('Host', upstreamDomain);
headers.set('Origin', `https://${upstreamDomain}`);
headers.set('Referer', url.href);
return new Request(url.href, {
method: originalRequest.method,
headers: headers,
body: originalRequest.body
});
}
// 处理响应
async function processResponse(response, upstreamDomain, hostName) {
const responseHeaders = new Headers(response.headers);
// 清理响应头
responseHeaders.set('access-control-allow-origin', '*');
responseHeaders.delete('content-security-policy');
const contentType = responseHeaders.get('content-type') || '';
if (contentType.includes('text/html')) {
const text = await response.text();
const processedText = await transformHTML(text, upstreamDomain, hostName);
return new Response(processedText, {
status: response.status,
headers: responseHeaders
});
}
return new Response(response.body, {
status: response.status,
headers: responseHeaders
});
}
// HTML转换函数
async function transformHTML(html, upstreamDomain, hostName) {
// 徽章移除正则表达式集合
const BADGE_REMOVAL_PATTERNS = [
/<a\s+href="https:\/\/s\.super\.so\/badge"[^>]*>.*?<\/a>/gis,
/<div\s+class="super-badge"[^>]*>.*?<\/div>/gis,
/<span>Made with Super<\/span>/gis,
/<img[^>]*src="[^"]*super-icon\.svg"[^>]*>/gis,
/class="super-badge"/gis
];
// 移除徽章元素
let processedHTML = html;
BADGE_REMOVAL_PATTERNS.forEach(pattern => {
processedHTML = processedHTML.replace(pattern, '');
});
// 注入强力CSS
const REMOVAL_CSS = `
<style>
.super-badge,
[class*="super-badge"],
a[href*="s.super.so/badge"],
#super-badge {
display: none !important;
visibility: hidden !important;
opacity: 0 !important;
position: absolute !important;
width: 0 !important;
height: 0 !important;
pointer-events: none !important;
z-index: -9999 !important;
}
body *:contains("Made with Super") {
display: none !important;
}
</style>`;
// 插入CSS
processedHTML = processedHTML.replace(
/<\/head>/i,
`${REMOVAL_CSS}</head>`
);
// 额外文本清理
processedHTML = processedHTML
.replace(/Made with Super/gi, '')
.replace(/Super Badge/gi, '');
// 域名替换
processedHTML = processedHTML.replace(
new RegExp(upstreamDomain, 'g'),
hostName
);
return processedHTML;
}
// 设备检测
async function detectDevice(request) {
const userAgent = request.headers.get('user-agent') || '';
const mobileAgents = [
"Android", "iPhone", "iPad", "iPod",
"Windows Phone", "SymbianOS"
];
return !mobileAgents.some(agent =>
userAgent.includes(agent)
);
}




