Class: ICAPrb::Plugins::RemovePlusOneButton
- Inherits:
-
Object
- Object
- ICAPrb::Plugins::RemovePlusOneButton
- Defined in:
- lib/icaprb/filter/solution.rb
Overview
Plug in to remove the Google PlusOne Button
Constant Summary collapse
- PLUGIN_NAME =
class name
'remove_plusone_button'- MODES =
Available mod modes
[:response_mod]
Instance Method Summary collapse
-
#initialize(_, _) ⇒ RemovePlusOneButton
constructor
mode- resp or req mod
parameters -
All parameters given in the configuration file.
- resp or req mod
-
#plugin(data) ⇒ Object
execute the plug in.
Constructor Details
#initialize(_, _) ⇒ RemovePlusOneButton
mode-
resp or req mod
parameters-
All parameters given in the configuration file
430 431 |
# File 'lib/icaprb/filter/solution.rb', line 430 def initialize(_, _) end |
Instance Method Details
#plugin(data) ⇒ Object
execute the plug in
440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 |
# File 'lib/icaprb/filter/solution.rb', line 440 def plugin(data) mod = false doc = Nokogiri::HTML(data[:http_response_body]) # removes all g-plusone elements doc.search('div.g-plusone').each do |src| src.remove mod = true end # removes all matching links doc.search('a').each do |a| if a['href'].to_s.match(/plus\.google\.com\/share\?/i) end end # removes all scripts where the source or the content matches doc.css('script').each do |script| if script['src'] == 'https://apis.google.com/js/platform.js' || script.content.match(/apis\.google\.com/i) script.remove mod = true end end # removes all iframes where the source matches doc.search('iframe').each do |iframe| if iframe['src'].match(/apis\.google\.com/i) iframe.remove mod = true end end data[:http_response_body] = doc.to_s if mod mod end |