Class: ICAPrb::Plugins::RemovePiwikTracker
- Inherits:
-
Object
- Object
- ICAPrb::Plugins::RemovePiwikTracker
- Defined in:
- lib/icaprb/filter/solution.rb
Overview
Plug in to remove the Piwik Tracker
Constant Summary collapse
- PLUGIN_NAME =
class name
'remove_piwik_tracker'- MODES =
Available mod modes
[:response_mod]
Instance Method Summary collapse
-
#initialize(_, _) ⇒ RemovePiwikTracker
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 removes all scripts where the source or the content matches.
Constructor Details
#initialize(_, _) ⇒ RemovePiwikTracker
mode-
resp or req mod
parameters-
All parameters given in the configuration file
792 793 |
# File 'lib/icaprb/filter/solution.rb', line 792 def initialize(_, _) end |
Instance Method Details
#plugin(data) ⇒ Object
execute the plug in removes all scripts where the source or the content matches
803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 |
# File 'lib/icaprb/filter/solution.rb', line 803 def plugin(data) mod = false #stops loading from specific host if data[:http_request_header]['Host'].to_s.match(/demo[0-9]+\.piwik\.org/i) data[:http_response_body] = '' mod = true end doc = Nokogiri::HTML(data[:http_response_body]) doc.search('script').each do |script| if script['src'].to_s.match(/piwik\.js/i) || script.content.match(/piwik\.js/i) script.remove mod = true end end data[:http_response_body] = doc.to_s if mod mod end |