From b4cdd31c2a394023c7c775128a1fe637ef7d598d Mon Sep 17 00:00:00 2001 From: Phyks Date: Sun, 4 Aug 2013 23:38:42 +0200 Subject: [PATCH] Should now do the same with flash objects too. TODO : Elegant degradation and click to play. --- README.md | 4 +++- adblock/adblock.plugin.disabled.php | 10 ++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 9b7492a..8bddd23 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,9 @@ This is a plugin for Leed written by Phyks (phyks@phyks.me) to allow a leed user This behavior can be fully customized in a per feed way (with either a blacklist or a whitelist). You can also choose to disable images only on mobile browsers. -**Important note :** To install the plugin, just do as usual with leed plugins. The adblock folder goes in the plugins directory of your leed installation. **Don't rename** the adblock directory unless you know what you do (you will need to change some paths values in the script itself). +**Important note :** To install the plugin, just do as usual with leed plugins. The adblock folder goes in the plugins directory of your leed installation. **Don't rename** the adblock directory unless you know what you do (you will need to change some paths values in the script itself). For an elegant degradation, _ie_ replacement of the deleted content by neutral content of the same size, you will need the GD library. + +**Note :** This will replace all images (found by searching for <img> tags) and all embedded objects (found by searching for <object> tags). This will only mask them when you display the page (and not load them) on a server side. If you click on the replacement content, it will load the masked content. ## Constants (_adblock_constants.php_ file) diff --git a/adblock/adblock.plugin.disabled.php b/adblock/adblock.plugin.disabled.php index 3d38ba8..5c80b60 100755 --- a/adblock/adblock.plugin.disabled.php +++ b/adblock/adblock.plugin.disabled.php @@ -76,7 +76,13 @@ function adblock_plugin_treat_events(&$events) { if($filter_flash) { if(($block_flash && !in_array($event->getFeed(), $flash_except_list)) || (!$block_flash && in_array($event->getFeed(), $flash_except_list))) { //Replace flash content - $event->setContent($filered_content); // TODO + $object_list_in_event = preg_match_all("#.{0,}#U", $filtered_content); + + foreach($object_list_in_event as $object) { + $filtered_content = str_replace($object[0], "", $filtered_content); + } + + $event->setContent($filtered_content); } } @@ -87,7 +93,7 @@ function adblock_plugin_treat_events(&$events) { $img_list_in_event = preg_match_all("##U", $filtered_content); foreach($img_list_in_event as $img) { - $filtered_event = str_replace($img[0], "", $filtered_content); + $filtered_content = str_replace($img[0], "", $filtered_content); } $event->setContent($filtered_content);