diff --git a/README.md b/README.md index 8bddd23..7dcba93 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ This behavior can be fully customized in a per feed way (with either a blacklist **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. +**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. So, the content is always downloaded from the external server to your running leed instance, but is only downloaded on-demand from to your device. ## Constants (_adblock_constants.php_ file) diff --git a/adblock/adblock.plugin.disabled.php b/adblock/adblock.plugin.disabled.php index 5c80b60..c31f301 100755 --- a/adblock/adblock.plugin.disabled.php +++ b/adblock/adblock.plugin.disabled.php @@ -68,6 +68,7 @@ function adblock_plugin_treat_events(&$events) { $img_except_list = explode(',', trim($adblock_params["img_list"], "\t\n\r\0\x0B,")); $img_except_list = adblock_trim_list($flash_except_list); + $elegant_degradation = (isset($adblock_params["elegant_degradation"]) && $adblock_params["elegant_degradation"] == "1") ? true : false; foreach($events as $event) { $filtered_content = $event->getContent(); @@ -79,7 +80,12 @@ function adblock_plugin_treat_events(&$events) { $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); + if($elegant_degradation) { + $filtered_content = str_replace($object[0], "", $filtered_content); + } + else { + + } } $event->setContent($filtered_content); @@ -93,7 +99,12 @@ function adblock_plugin_treat_events(&$events) { $img_list_in_event = preg_match_all("##U", $filtered_content); foreach($img_list_in_event as $img) { - $filtered_content = str_replace($img[0], "", $filtered_content); + if($elegant_degradation) { + $filtered_content = str_replace($img[0], "", $filtered_content); + } + else { + + } } $event->setContent($filtered_content); @@ -134,6 +145,10 @@ function adblock_plugin_setting_bloc(&$myUser) { else $img_list = ""; + $elegant_degradation = (isset($adblock_params["elegant_degradation"]) && $adblock_params["elegant_degradation"] == "1") ? true : false; + + $gd_available = function_exists("getimagesize"); + echo '
@@ -182,6 +197,11 @@ function adblock_plugin_setting_bloc(&$myUser) { +

+ Elegant degradation (replace content with same-size content) ?
+ '.((!$gd_available) ? ' (Not available because GD seems to not be installed on your system)' : '').'
+ +

@@ -202,7 +222,9 @@ function adblock_plugin_setting_update($_) { $img_list = str_replace("\r\n", ",", trim($_["img_adblock_list"])); $img_list = str_replace("\n", ",", trim($img_list)); - if(file_put_contents("plugins/adblock/adblock_constants.php", "flash_enabled = ".$flash_enabled."\nflash_block = ".$flash_block."\nflash_list = ".$flash_list."\nimg_enabled = ".$img_enabled."\nimg_block = ".$img_block."\nimg_only_mobiles = ".$img_only_mobiles."\nimg_list = ".$img_list)) + $elegant_degradation = (int) $_["adblock_elegant_degradation"]; + + if(file_put_contents("plugins/adblock/adblock_constants.php", "flash_enabled = ".$flash_enabled."\nflash_block = ".$flash_block."\nflash_list = ".$flash_list."\nimg_enabled = ".$img_enabled."\nimg_block = ".$img_block."\nimg_only_mobiles = ".$img_only_mobiles."\nimg_list = ".$img_list."\nelegant_degradation = ".$elegant_degradation)) header('location: settings.php'); else exit("Unable to write parameters to plugins/adblock/adblock_constants.php. Check permissions on the folders."); diff --git a/adblock/adblock_constants.php b/adblock/adblock_constants.php index 96d7f49..64ef612 100755 --- a/adblock/adblock_constants.php +++ b/adblock/adblock_constants.php @@ -5,3 +5,4 @@ img_enabled = 0 img_block = 0 img_only_mobiles = 0 img_list = +elegant_degradation = diff --git a/adblock/install.php b/adblock/install.php index da58e45..a87132c 100644 --- a/adblock/install.php +++ b/adblock/install.php @@ -1,3 +1,5 @@