From 73036b29734495d420472f06ded4a6ef942ebbd6 Mon Sep 17 00:00:00 2001 From: Alexei Bezborodov Date: Sun, 29 Oct 2023 11:19:01 +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=D0=B0=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=20?= =?UTF-8?q?=D0=97=D0=92=20=D0=B8=20=D0=B8=D0=BC=D1=8F=20=D1=85=D0=BE=D1=81?= =?UTF-8?q?=D1=82=D0=B0=20=D0=B2=20=D0=B8=D0=BD=D0=BE=D1=82=D0=B2=20#8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- news_parser.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/news_parser.js b/news_parser.js index aebf395..33cd70a 100644 --- a/news_parser.js +++ b/news_parser.js @@ -277,9 +277,13 @@ return FinishWorkFunc } + function FinishWorkFuncZV(a_Element, a_ElementIndex) { + return GrubTextFuncTemplate()(a_Element); + } + // Создание контента для стандартных новостей const title_tag = 'h2'; - const title_finish_text_func = FinishWorkFuncTemplate(title_tag, 'center') + 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'; @@ -300,6 +304,7 @@ let source_add = true; const zero_tag_func = FinishWorkFuncTemplate() const grub_text_func = GrubTextFuncTemplate() + let host_name = null; if (location.hostname == 'tass.ru') { // test: https://tass.ru/proisshestviya/19117971 @@ -399,6 +404,9 @@ ), [] ); + if (content.length > 0) { + host_name = 'inotv'; + } } } else if (location.hostname == 'www.cnews.ru') { @@ -422,9 +430,9 @@ } else if (location.hostname == 'zakonvremeni.ru') { const base_element = document.getElementsByClassName('item-page')[0]; - const title = GetContentInContainers(FindElementsByRegExp(GetElementClassName, 'page-header', base_element), grub_text_func); - const parent_category = GetContentInContainers(FindElementsByRegExp(GetElementClassName, 'parent-category-name', base_element), grub_text_func); - const category = GetContentInContainers(FindElementsByRegExp(GetElementClassName, 'category-name', base_element), grub_text_func); + const title = GetContentInContainers(FindElementsByRegExp(GetElementClassName, 'page-header', base_element), grub_text_func, FinishWorkFuncZV); + const parent_category = GetContentInContainers(FindElementsByRegExp(GetElementClassName, 'parent-category-name', base_element), grub_text_func, FinishWorkFuncZV); + const category = GetContentInContainers(FindElementsByRegExp(GetElementClassName, 'category-name', base_element), grub_text_func, FinishWorkFuncZV); const page = RemoveAfterSplitter(TrimString(document.getElementsByClassName('item-page')[0].querySelector('[itemprop=articleBody]').textContent), '.', true); content = title + '\n' + parent_category + ' ' + category + '\n\n' + page + '\n' + document.URL; source_add = false; @@ -434,7 +442,7 @@ if (content.length > 0) { result = ''; }