From 3a3be01c88229e9f881c7dd021f4e1efec8d3727 Mon Sep 17 00:00:00 2001 From: Matt Baer Date: Wed, 30 Aug 2017 22:45:22 -0400 Subject: [PATCH 1/3] Add option to disable dynamic/lazy image loading This ensures all images in a post load immediately, instead of waiting for the user to scroll down the page. Closes #5 --- background.js | 15 +++++++++++++++ options.html | 4 ++++ options.js | 8 ++++++-- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/background.js b/background.js index c10c0fe..89d8a50 100644 --- a/background.js +++ b/background.js @@ -20,6 +20,18 @@ var hideDickbar = function() { document.querySelector('footer > .container:first-child').style.display = 'none'; }; +var disableLazyLoading = function() { + var hiddenMedia = document.querySelectorAll('.js-progressiveMedia-inner'); + if (hiddenMedia == null) { + return; + } + for (var i=0; i in the document var metaCheck = document.head.querySelector('meta[property="al:ios:app_name"]'); @@ -30,5 +42,8 @@ if (metaCheck != null && metaCheck.content == "Medium") { if (items.hideDickbar) { hideDickbar(); } + if (items.disableLazyImages) { + disableLazyLoading(); + } }); } diff --git a/options.html b/options.html index de09b5e..3927974 100644 --- a/options.html +++ b/options.html @@ -21,6 +21,10 @@ Hide sharing dickbar + +

Defaults

diff --git a/options.js b/options.js index 27de99d..6d9a95e 100644 --- a/options.js +++ b/options.js @@ -1,8 +1,10 @@ // Saves options to chrome.storage function save_options() { var hideDickbar = document.getElementById('dickbar').checked; + var disableLazyImages = document.getElementById('images').checked; chrome.storage.sync.set({ - hideDickbar: hideDickbar + hideDickbar: hideDickbar, + disableLazyImages: disableLazyImages }, function() { // Update status to let user know options were saved. var status = document.getElementById('status'); @@ -17,9 +19,11 @@ function save_options() { // stored in chrome.storage. function restore_options() { chrome.storage.sync.get({ - hideDickbar: false + hideDickbar: false, + disableLazyImages: false }, function(items) { document.getElementById('dickbar').checked = items.hideDickbar; + document.getElementById('images').checked = items.disableLazyImages; }); } document.addEventListener('DOMContentLoaded', restore_options); From 2cfbf290545c2106ed5c402a12a47f53b78b116a Mon Sep 17 00:00:00 2001 From: Matt Baer Date: Wed, 30 Aug 2017 22:59:07 -0400 Subject: [PATCH 2/3] Mention new lazy loading option in README --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 1c160c1..cd4a383 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,7 @@ This is that Chrome extension. [Install it here](https://chrome.google.com/webst * Keeping the top navigation bar from sticking around * Hiding the bottom "Get Updates" bar completely * (Optionally) hiding the clap / share bar +* (Optionally) loading all post images up front, instead of lazy loading as you scroll ### Preview From 9d0d8e139b33741ea8bcc065636be96e3fdb8f32 Mon Sep 17 00:00:00 2001 From: Matt Baer Date: Wed, 30 Aug 2017 23:12:41 -0400 Subject: [PATCH 3/3] Check for null dickbars before applying styles --- background.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/background.js b/background.js index 89d8a50..7e19b6b 100644 --- a/background.js +++ b/background.js @@ -16,8 +16,14 @@ var makeReadable = function() { }; var hideDickbar = function() { - document.querySelector('.js-postShareWidget').style.display = 'none'; - document.querySelector('footer > .container:first-child').style.display = 'none'; + var dickbar = document.querySelector('.js-postShareWidget'); + if (dickbar != null) { + dickbar.style.display = 'none'; + } + var footerDickbar = document.querySelector('footer > .container:first-child'); + if (footerDickbar != null) { + footerDickbar.style.display = 'none'; + } }; var disableLazyLoading = function() {