Update index.js
Browse files
index.js
CHANGED
@@ -20,6 +20,9 @@ function extractStringAfterRp(url) {
|
|
20 |
|
21 |
|
22 |
app.get('/*', async (req, res) => {
|
|
|
|
|
|
|
23 |
// 启动浏览器
|
24 |
const browser = await puppeteer.launch({
|
25 |
executablePath: '/usr/bin/google-chrome-stable', // 根据您的实际路径进行修改
|
@@ -52,7 +55,7 @@ app.get('/*', async (req, res) => {
|
|
52 |
if (matches) {
|
53 |
matches.forEach(match => {
|
54 |
const scriptUrl = match.replace(/'/g, "")
|
55 |
-
scripts += `<script src="https
|
56 |
})
|
57 |
}
|
58 |
return { scripts, cibname, htmlContent };
|
@@ -73,7 +76,7 @@ app.get('/*', async (req, res) => {
|
|
73 |
// 删除掉不需要的部分
|
74 |
let extractedString = coreContent[0];
|
75 |
extractedString = extractedString.replace('[CDATA[', '').replace('//]]', '').replace('https:\/\/r.bing.com', '');
|
76 |
-
extractedString = extractedString.replace(/\\\/rp\\\//g, 'https
|
77 |
extractedString = extractedString.replace(/https:\\\/\\\/r\.bing\.com/g, ''); // 删除 https:\/\/r.bing.com 字符串
|
78 |
res.set('Content-Type', 'text/plain');
|
79 |
res.send(extractedString); // 发送提取后的字符串
|
|
|
20 |
|
21 |
|
22 |
app.get('/*', async (req, res) => {
|
23 |
+
const referer = req.headers.referer || "https://cfby.nbing.eu.org";
|
24 |
+
const url = new URL(referer);
|
25 |
+
const rehost = url.hostname;
|
26 |
// 启动浏览器
|
27 |
const browser = await puppeteer.launch({
|
28 |
executablePath: '/usr/bin/google-chrome-stable', // 根据您的实际路径进行修改
|
|
|
55 |
if (matches) {
|
56 |
matches.forEach(match => {
|
57 |
const scriptUrl = match.replace(/'/g, "")
|
58 |
+
scripts += `<script src="https://${rehost}/rp${scriptUrl}"></script>\n`
|
59 |
})
|
60 |
}
|
61 |
return { scripts, cibname, htmlContent };
|
|
|
76 |
// 删除掉不需要的部分
|
77 |
let extractedString = coreContent[0];
|
78 |
extractedString = extractedString.replace('[CDATA[', '').replace('//]]', '').replace('https:\/\/r.bing.com', '');
|
79 |
+
extractedString = extractedString.replace(/\\\/rp\\\//g, 'https://${rehost}/rp/');
|
80 |
extractedString = extractedString.replace(/https:\\\/\\\/r\.bing\.com/g, ''); // 删除 https:\/\/r.bing.com 字符串
|
81 |
res.set('Content-Type', 'text/plain');
|
82 |
res.send(extractedString); // 发送提取后的字符串
|