tglinks.js 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. if(!$response){
  2. return
  3. }
  4. let html = $response.body || '';
  5. let regex = /<a class="tgme_action_button_new shine" href="([\S]+)">([^<]+)<\/a>/;
  6. console.log("###tglinks###");
  7. console.log(html)
  8. // let regex = /<div class="tgme_page_action">\s*<a class="tgme_action_button_new shine" href="([\S]+)">([^<]+)<\/a>\s*<\/div>/;
  9. // let matches = html.match(regex);
  10. // if (matches) {
  11. // let allContent = matches[0];
  12. // let originalHref = matches[1];
  13. // let originalText = matches[2];
  14. // console.log(originalHref);
  15. // console.log(originalText);
  16. // // 定义新的href和链接文本
  17. // let newHref = originalHref.replace('tg://', 'ncg://');
  18. // let newText = 'View on Nicegram';
  19. // let replacement = `<a class="tgme_action_button_new shine" href="${newHref}">${newText}</a>`;
  20. // let newHtmlStr = html.replace(regex, matches[0]+'\n'+replacement);
  21. // let regex2 = /var\s*protoUrl\s*=\s*"([^"]+)"/;
  22. // newHtmlStr = newHtmlStr.replace(regex, 'var protoUrl=null');
  23. // newHtmlStr = newHtmlStr.replace('if\s*\(true\)\s*\{', 'if (false) {');
  24. // html = newHtmlStr;
  25. // }
  26. $done({
  27. body: html
  28. });