tglinks.js 1.0 KB

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