shawenguan 2 лет назад
Родитель
Сommit
84dda364d7
2 измененных файлов с 22 добавлено и 4 удалено
  1. 20 2
      Scripts/tglinks/tglinks.js
  2. 2 2
      Scripts/tglinks/tglinks.rewirte.quanx.conf

+ 20 - 2
Scripts/tglinks/tglinks.js

@@ -1,3 +1,21 @@
 
-let openlink = $request.url.replace('tg://', 'ng://');
-notify("", "点击跳转到Nickgram打开", openlink, openlink);
+
+let html = $response.body || '';
+let regex = /<a class="tgme_action_button_new shine" href="([^"]+)">([^<]+)<\/a>/;
+
+let regex = /<div class="tgme_page_action">\s*<a class="tgme_action_button_new shine" href="([^"]+)">([^<]+)<\/a>\s*<\/div>/;
+let matches = html.match(regex);
+if (matches) {
+    let allContent = matches[0];
+    let originalHref = matches[1];
+    let originalText = matches[2];
+    // 定义新的href和链接文本
+    let newHref = originalHref.replace('tg://', 'ncg://');
+    let newText = 'View on Nicegram';
+    let replacement = `<a class="tgme_action_button_new shine" href="${newHref}">${newText}</a>`;
+    let newHtmlStr = html.replace(regex, matches[0]+'\n'+replacement);
+    html = newHtmlStr;
+}
+$.done({
+  body: html
+});

+ 2 - 2
Scripts/tglinks/tglinks.rewirte.quanx.conf

@@ -1,3 +1,3 @@
-hostname = tg
+hostname = t.me
 
-^tg:\/\/ url script-request-body https://git.jojo21.cf/shawenguan/Quantumult-X/raw/master/Scripts/tglinks/tglinks.js
+^https?:\/\/t.me url script-response-body https://git.jojo21.cf/shawenguan/Quantumult-X/raw/master/Scripts/tglinks/tglinks.js