Skip to content

Instantly share code, notes, and snippets.

@cor-bee
Last active October 10, 2020 13:24
Show Gist options
  • Save cor-bee/1da96dc295f2645895bab2f4347cbcce to your computer and use it in GitHub Desktop.
Save cor-bee/1da96dc295f2645895bab2f4347cbcce to your computer and use it in GitHub Desktop.
Handlers for IV errors
# NESTED_ELEMENT_NOT_SUPPORTED Error Handler
?true
$problems: $body
@while( $problems ) {
$test: $body//*[self::*[has-class("fb-post")] or self::blockquote or self::aside or self::figure or self::img[not(./ancestor::figure)] or self::iframe[not(./ancestor::figure)] or self::script[@data-telegram-post] or self::slideshow[not(./ancestor::figure)] or self::video[not(./ancestor::figure)] or self::audio[not(./ancestor::figure)] or self::related or self::footer or self::table[not(ancestor::table) and not(descendant::table)]]
$problems: $test/self::*[ancestor::anchor or ancestor::blockquote[not(contains(@class,"instagram"))] or ancestor::aside or ancestor::footer or ancestor::strong or ancestor::b or ancestor::em or ancestor::i or ancestor::ins or ancestor::u or ancestor::del or ancestor::s or ancestor::strike or ancestor::code or ancestor::kbd or ancestor::samp or ancestor::tt or ancestor::mark or ancestor::sup or ancestor::pic or ancestor::sub or ancestor::a or ancestor::reference or ancestor::h1 or ancestor::h2 or ancestor::h3 or ancestor::h4 or ancestor::h5 or ancestor::h6 or ancestor::p or ancestor::pre or ancestor::hr or ancestor::img or ancestor::br]
@split_parent: $problems
}
# EMBED_ELEMENT_NOT_SUPPORTED Error Handler
@unsupported: //body[has-class("t-body")] # Tilda sites not supported
@unsupported: $body//*[text()[contains(., "$latex")]]
@unsupported: $body//div[has-class("apester-media")]
@unsupported: $body//div[has-class("issuuembed")]
@unsupported: $body//div[has-class("juxtapose")]
@unsupported: $body//div[has-class("piktowrapper-embed")]
@unsupported: $body//div[has-class("playbuzz")]
@unsupported: $body//div[has-class("scrbbl-embed")]
@unsupported: $body//div[has-class("quizz-container")]
@unsupported: $body//div[starts-with(@class, "wtf-broadcast")]
@unsupported: $body//div[has-class("articlevideo") and not(@data-type="instagram")]
@unsupported: $body//script[contains(., "apester.") or contains(@src, "apester.")]
@unsupported: $body//script[contains(., "playbuzz.") or contains(@src, "playbuzz.")]
@unsupported: $body//script[contains(@src, "leaflet")]
@unsupported: $body//script[contains(text(), "opinionstage")]
# Remove unwanted elements
@remove: //button
@remove: //script
@remove: //noscript
@remove: //xml
@remove: //img[ends-with(@src, ".svg")]
@remove: //pic[ends-with(@src, ".svg")]
# Lazyload images fix
@set_attrs(src, @data-lazy-src, srcset, @data-lazy-srcset, src, @data-src, srcset, @data-srcset, src, @data-original, src, @data-wpfc-original-src, srcset, @data-wpfc-original-srcset, src, @data-layzr, srcset, @data-layzrset, src, @data-gmsrc, src, @data-link, srcset, @data-linkset): //*

Authors:

  • Misho @mushi_f
  • Andrei Afanasiev
  • Illia Pyshniak @corbee
  • Mikhail Komendant

Need help?

Ask your question in comments or in Instant View Chats (eng, ru)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment