if(!$response){ return } let html = $response.body || ''; console.log("###tglinks###"); let regex = /
\s*([^<]+)<\/a>\s*<\/div>/; let matches = html.match(regex); console.log(JSON.stringify(matches)); if (matches) { let allContent = matches[0]; let originalHref = matches[1]; let originalText = matches[2]; console.log(originalHref); console.log(originalText); // 定义新的href和链接文本 let newHref = originalHref.replace('tg://', 'ncg://'); let newText = 'View on Nicegram'; let replacement = `
${newText}
`; let newHtmlStr = html.replace(allContent, allContent+'\n'+replacement); let regex2 = /var\s*protoUrl\s*=\s*"([\S]+)"/; newHtmlStr = newHtmlStr.replace(regex2, 'var protoUrl=null'); newHtmlStr = newHtmlStr.replace('if\s*\(true\)\s*\{', 'if (false) {'); html = newHtmlStr; } $done({ body: html });