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