Remove small images from reformatted messages

pull/184/head
M66B 4 years ago
parent 7485ded3eb
commit c8b6ece9af

@ -2017,7 +2017,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
boolean disable_tracking = prefs.getBoolean("disable_tracking", true); boolean disable_tracking = prefs.getBoolean("disable_tracking", true);
if (disable_tracking) if (disable_tracking)
HtmlHelper.removeTrackingPixels(context, document); HtmlHelper.removeTrackingPixels(context, document, true);
if (debug) { if (debug) {
Document format = JsoupEx.parse(file); Document format = JsoupEx.parse(file);

@ -833,7 +833,7 @@ public class HtmlHelper {
// Remove tracking pixels // Remove tracking pixels
if (disable_tracking) if (disable_tracking)
removeTrackingPixels(context, document); removeTrackingPixels(context, document, false);
// Images // Images
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img // https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img
@ -1427,7 +1427,7 @@ public class HtmlHelper {
return sb.toString(); return sb.toString();
} }
static void removeTrackingPixels(Context context, Document document) { static void removeTrackingPixels(Context context, Document document, boolean full) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean disconnect_images = prefs.getBoolean("disconnect_images", false); boolean disconnect_images = prefs.getBoolean("disconnect_images", false);
@ -1461,14 +1461,21 @@ public class HtmlHelper {
// Images // Images
for (Element img : document.select("img")) { for (Element img : document.select("img")) {
img.removeAttr("x-tracking"); img.removeAttr("x-tracking");
String src = img.attr("src"); String src = img.attr("src");
if (TextUtils.isEmpty(src)) if (TextUtils.isEmpty(src)) {
if (!full)
img.remove();
continue; continue;
}
Uri uri = Uri.parse(src); Uri uri = Uri.parse(src);
String host = uri.getHost(); String host = uri.getHost();
if (host == null || hosts.contains(host)) if (host == null || hosts.contains(host)) {
if (!full && isTrackingPixel(img)) // Is small image
img.remove();
continue; continue;
}
if (isTrackingPixel(img) || if (isTrackingPixel(img) ||
(disconnect_images && DisconnectBlacklist.isTracking(host))) { (disconnect_images && DisconnectBlacklist.isTracking(host))) {

Loading…
Cancel
Save