shawenguan 2 роки тому
батько
коміт
ccbe3474e1
1 змінених файлів з 11 додано та 0 видалено
  1. 11 0
      Scripts/tghelper/tgLinksHelper.js

+ 11 - 0
Scripts/tghelper/tgLinksHelper.js

@@ -1,8 +1,14 @@
 const lk = new ToolKit(`TG-Links助手`, `TgLinksHelper`);
 
 let htmlText = $response.body || '';
+let styleType = 1;
 let regex = /<div class="tgme_page_action">\s*<a class="tgme_action_button_new shine" href="([\S]+)">([^<]+)<\/a>\s*<\/div>/;
 let matches = htmlText.match(regex);
+if(!matches){
+    styleType = 2;
+    regex = /<div class="tgme_page_action">\s*<a class="tgme_action_button_new" href="([\S]+)">([^<]+)<\/a>\s*<\/div>/;
+    matches = htmlText.match(regex);
+}
 if (matches) {
     let tgToNcgNotifyFlag = lk.getVal('lkTgToNcgNotifyFlag', 'true');
     tgToNcgNotifyFlag = lk.isEmpty(tgToNcgNotifyFlag) ? true : JSON.parse(tgToNcgNotifyFlag);
@@ -15,7 +21,12 @@ if (matches) {
     // 定义新的href和链接文本
     let newHref = originalHref.replace('tg://', 'ncg://');
     let newText = 'View on Nicegram';
+
     let ncgDivHtml = `<div class="tgme_page_action"><a class="tgme_action_button_new shine" href="${newHref}">${newText}</a></div>`;
+    if(styleType == 2){
+        ncgDivHtml = `<div class="tgme_page_action"><a class="tgme_action_button_new" href="${newHref}">${newText}</a></div>`;
+    }
+
     let rHtmlText = htmlText.replace(mContent, mContent+'\n'+ncgDivHtml);
 
     rHtmlText = rHtmlText.replace(/if\s*\(true\)\s*\{/, 'if (false) {');