5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/detergent/matchers/removable_node_matcher.rb', line 5
def match?(node)
if node.name.downcase == "button"
aria_label = node['aria-label'].to_s.downcase
return true if ["share", "save"].include?(aria_label)
end
if node.name.downcase == "nav"
return true if node['role'].to_s.downcase == "navigation"
end
return true if %w(link iframe script style footer nav form select textarea).include?(node.name.downcase)
class_list = node['class'].to_s.downcase.split(" ")
return true if class_list.any?{ %w(comments-show comments actionbar related-stories navigation nodisplay sidebar admz hidden header footer social share).include?(_1) }
id_list = node['id'].to_s.downcase.split(" ")
return true if id_list.any?{ %w(header navigation ad admz sidebar related-stories hidden).include?(_1) }
style_list = node['style'].to_s.downcase.split(";")
return true if style_list.any?{ ["display: none", "display:none"].include?(_1) }
return false if %w(img picture figure).include?(node.name.downcase)
return false if node.xpath(".//img | .//picture | .//figure").any?
node.xpath(".//text()[normalize-space()]").empty?
end
|