diff --git a/src/lib/constants.js b/src/lib/constants.js index 211a1cf..473ee54 100644 --- a/src/lib/constants.js +++ b/src/lib/constants.js @@ -41,6 +41,11 @@ let constants = { does_not_track: false, allow_user_from_reel: "fallback", // one of: "never", "fallback", "prefer", "onlyPreferSaved", "preferForRSS" + proxy_media: { // Whether to proxy media (images, videos, thumbnails) through Bibliogram. This is strongly recommended to protect user privacy. If proxy is turned off, some browser content blockers may break all images since they are served from Facebook domains. + image: true, + video: true, + thumbnail: true + }, feeds: { // Whether feeds are enabled. diff --git a/src/lib/structures/TimelineBaseMethods.js b/src/lib/structures/TimelineBaseMethods.js index a176a3a..84d5c94 100644 --- a/src/lib/structures/TimelineBaseMethods.js +++ b/src/lib/structures/TimelineBaseMethods.js @@ -26,11 +26,15 @@ class TimelineBaseMethods { } getDisplayUrlP() { - return proxyImage(this.data.display_url) + let url = this.data.display_url + if (constants.proxy_media.image) url = proxyImage(url) + return url } getVideoUrlP() { - return proxyVideo(this.data.video_url) + let url = this.data.video_url + if (constants.proxy_media.video) url = proxyVideo(url) + return url } getAlt() { diff --git a/src/lib/structures/TimelineEntry.js b/src/lib/structures/TimelineEntry.js index 253f76c..cea1835 100644 --- a/src/lib/structures/TimelineEntry.js +++ b/src/lib/structures/TimelineEntry.js @@ -154,7 +154,9 @@ class TimelineEntry extends TimelineBaseMethods { getThumbnailSrcsetP() { if (this.data.thumbnail_resources) { return this.data.thumbnail_resources.map(tr => { - return `${proxyImage(tr.src, tr.config_width)} ${tr.config_width}w` + let src = tr.src + if (constants.proxy_media.thumbnail) src = proxyImage(tr.src, tr.config_width) + return `${src} ${tr.config_width}w` }).join(", ") } else { return null @@ -174,16 +176,20 @@ class TimelineEntry extends TimelineBaseMethods { found = tr if (tr.config_width >= size) break // don't proceed once we find one large enough } + let src = found.src + if (constants.proxy_media.thumbnail) src = proxyImage(src, found.config_width) // force resize to config rather than requested return { config_width: found.config_width, config_height: found.config_height, - src: proxyImage(found.src, found.config_width) // force resize to config rather than requested + src } } else if (this.data.thumbnail_src) { + let src = this.data.thumbnail_src + if (constants.proxy_media.thumbnail) src = proxyImage(src, size) // force resize to requested return { config_width: size, // probably? config_height: size, - src: proxyImage(this.data.thumbnail_src, size) // force resize to requested + src } } else { return null