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);
if (disable_tracking)
HtmlHelper.removeTrackingPixels(context, document);
HtmlHelper.removeTrackingPixels(context, document, true);
if (debug) {
Document format = JsoupEx.parse(file);

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

Loading…
Cancel
Save