瀏覽代碼

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
tags/v1.2
Matt Baer 6 年之前
父節點
當前提交
3a3be01c88
共有 3 個文件被更改,包括 25 次插入2 次删除
  1. +15
    -0
      background.js
  2. +4
    -0
      options.html
  3. +6
    -2
      options.js

+ 15
- 0
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<hiddenMedia.length; i++) {
var template = document.createElement('template');
template.innerHTML = hiddenMedia[i].textContent;
hiddenMedia[i].parentNode.appendChild(template.content.firstChild);
}
};

// Only run this on Medium sites.
// Ensure that by checking for <meta property="al:ios:app_name" content="Medium"> in the document <head />
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();
}
});
}

+ 4
- 0
options.html 查看文件

@@ -21,6 +21,10 @@
<input type="checkbox" id="dickbar"> Hide sharing dickbar
</label>

<label>
<input type="checkbox" id="images"> Disable lazy image loading
</label>

<hr />

<h2>Defaults</h2>


+ 6
- 2
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);


Loading…
取消
儲存