From a8f1bae7c1c936de9d22abd359cf61057e17b201 Mon Sep 17 00:00:00 2001 From: Alexei Bezborodov Date: Wed, 13 Mar 2024 10:00:57 +0300 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D1=8B=20=D0=B7=D0=B0=D0=B3=D0=BE=D0=BB=D0=BE=D0=B2?= =?UTF-8?q?=D0=BA=D0=B8=20https://tass.ru/armiya-i-opk/20209529?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- news_parser.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/news_parser.js b/news_parser.js index efc92ba..b4e3405 100644 --- a/news_parser.js +++ b/news_parser.js @@ -1,7 +1,7 @@ // ==UserScript== // @name News parser // @namespace http://zakonvremeni.ru -// @version 0.3.9 +// @version 0.3.10 // @description Parse news // @author AlexeiBv+mirocod@narod.ru // @match https://tass.ru/* @@ -250,7 +250,7 @@ } }); - let tags_to_align = ['p', 'h2', 'li']; + let tags_to_align = ['p', 'h1', 'h2', 'h3', 'li']; tags_to_align.forEach(function (align_tag_name) { let elements = clear_element.querySelectorAll(align_tag_name); @@ -266,6 +266,7 @@ if (a_ClearTextFunc) { result = a_ClearTextFunc(result, a_ElementIndex); } + if (a_OutTag && a_TextAlign && TrimString(result).replace(' ', '') != '') { result = '<' + a_OutTag + ' style = "text-align:' + a_TextAlign + ';">' + result + ''; } @@ -273,11 +274,13 @@ } + const title_tag = 'h2'; + const p_tag = 'p'; function FinishWorkFuncTemplate(a_OutTag, a_TextAlign, a_ClearTextFunc, a_SubElementCheckerToRemove) { function FinishWorkFunc(a_Element, a_ElementIndex) { let out_tag = a_OutTag; - if (a_Element && CheckRegExp(GetElementClassName, 'Title_title.*', a_Element)) { - out_tag = 'h2'; + if (a_Element && a_OutTag == p_tag && CheckRegExp(GetElementClassName, 'Title_title.*', a_Element)) { + out_tag = 'h3'; } let a_Content = GetClearHtml(a_Element, out_tag, a_TextAlign, a_SubElementCheckerToRemove, a_ClearTextFunc, a_ElementIndex); @@ -295,11 +298,9 @@ } // Создание контента для стандартных новостей - const title_tag = 'h2'; const title_finish_text_func = FinishWorkFuncTemplate(title_tag, 'center'); function MakeContentByNews(a_BaseElementTitle, a_BaseElementImage, a_BaseElementText, a_TitleRegExpElementPattern, a_ImageRegExpElementPattern, a_TextRegExpElementPattern, a_ElementChecker, a_SubElementCheckerToRemove, a_ClearTextPatterns) { - const p_tag = 'p'; const grub_func = GrubTextFuncTemplate(); let content = ''; @@ -326,7 +327,7 @@ base_element, base_element, base_element, - '(ArticleHeader_titles|tass_pkg_title--variant_h1_default).*', + '(tass_pkg_title--variant_h1).*', '(Image_wrapper_|ImageSSR_image_.*)', '(CommonMaterialLayout_lead|Paragraph_paragraph|Title_title).*', ElementCheckerTrue,