From 48065e5d839a214e5286c0258d77314ad54ace2d Mon Sep 17 00:00:00 2001 From: Jim Miller Date: Wed, 21 Jul 2021 11:28:23 -0500 Subject: [PATCH] Add reveal_invisible_text option to base_xenforoforum_adapter. --- calibre-plugin/plugin-defaults.ini | 5 +++++ fanficfare/adapters/base_xenforoforum_adapter.py | 4 ++++ fanficfare/configurable.py | 2 ++ fanficfare/defaults.ini | 5 +++++ 4 files changed, 16 insertions(+) diff --git a/calibre-plugin/plugin-defaults.ini b/calibre-plugin/plugin-defaults.ini index 40428499..9d9a92c5 100644 --- a/calibre-plugin/plugin-defaults.ini +++ b/calibre-plugin/plugin-defaults.ini @@ -892,6 +892,11 @@ use_threadmark_wordcounts:true ## treat both threadmarks *and* first post links as chapter links. #always_include_first_post_chapters:false +## When reveal_invisible_text is set true, adapter will search for +## tags and remove the style +## attribute. +#reveal_invisible_text:false + [base_xenforoforum:epub] ## See remove_spoilers above for more about 'spoilers'. This example diff --git a/fanficfare/adapters/base_xenforoforum_adapter.py b/fanficfare/adapters/base_xenforoforum_adapter.py index f07c667a..cf5cc733 100644 --- a/fanficfare/adapters/base_xenforoforum_adapter.py +++ b/fanficfare/adapters/base_xenforoforum_adapter.py @@ -767,6 +767,10 @@ class BaseXenForoForumAdapter(BaseSiteAdapter): div.button.extract() def _do_utf8FromSoup(self,url,soup,fetch=None,allow_replace_br_with_p=True): + if self.getConfig('reveal_invisible_text'): + ## when set, remove style='color:transparent'. + for span in soup.find_all('span',style='color:transparent'): + del span['style'] if self.getConfig('replace_failed_smilies_with_alt_text'): for img in soup.find_all('img',src=re.compile(r'(^data:image|(failedtoload|clear.png)$)')): # logger.debug("replace_failed_smilies_with_alt_text img: %s"%img) diff --git a/fanficfare/configurable.py b/fanficfare/configurable.py index 31e93620..448f6cad 100644 --- a/fanficfare/configurable.py +++ b/fanficfare/configurable.py @@ -281,6 +281,7 @@ def get_valid_set_options(): 'use_threadmark_wordcounts':(base_xenforo_list,None,boollist), 'always_include_first_post_chapters':(base_xenforo_list,None,boollist), 'order_threadmarks_by_date':(base_xenforo_list,None,boollist), + 'reveal_invisible_text':(base_xenforo_list,None,boollist), 'use_threadmarks_description':(base_xenforo2_list,None,boollist), 'use_threadmarks_status':(base_xenforo2_list,None,boollist), 'use_threadmarks_cover':(base_xenforo2_list,None,boollist), @@ -520,6 +521,7 @@ def get_valid_keywords(): 'use_threadmark_wordcounts', 'always_include_first_post_chapters', 'order_threadmarks_by_date', + 'reveal_invisible_text', 'use_threadmarks_description', 'use_threadmarks_status', 'use_threadmarks_cover', diff --git a/fanficfare/defaults.ini b/fanficfare/defaults.ini index 28bfece4..7a890a8b 100644 --- a/fanficfare/defaults.ini +++ b/fanficfare/defaults.ini @@ -910,6 +910,11 @@ use_threadmark_wordcounts:true ## treat both threadmarks *and* first post links as chapter links. #always_include_first_post_chapters:false +## When reveal_invisible_text is set true, adapter will search for +## tags and remove the style +## attribute. +#reveal_invisible_text:false + [base_xenforoforum:epub] ## See remove_spoilers above for more about 'spoilers'. This example