|
|
|
@ -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 + '</' + a_OutTag + '>'; |
|
|
|
|
} |
|
|
|
@ -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, |
|
|
|
|