Skip to content

Commit efcb8be

Browse files
committed
Preprocess: remove ads
This removes Carbon ads script and style tags in HTML preprocessing. Fixes p12tic#5.
1 parent 02da161 commit efcb8be

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

commands/preprocess.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,14 @@ def preprocess_html_file(root, fn, rename_map):
309309
elif el.text is not None and ('google-analytics.com/ga.js' in el.text or 'pageTracker' in el.text):
310310
el.getparent().remove(el)
311311

312+
# remove Carbon ads
313+
for el in html.xpath('//script[@src]'):
314+
if 'carbonads.com/carbon.js' in el.get('src'):
315+
el.getparent().remove(el)
316+
for el in html.xpath('/html/body/style'):
317+
if el.text is not None and '#carbonads' in el.text:
318+
el.getparent().remove(el)
319+
312320
# apply changes to links caused by file renames
313321
for el in html.xpath('//*[@src or @href]'):
314322
if el.get('src') is not None:

0 commit comments

Comments
 (0)