Skip to content

Instantly share code, notes, and snippets.

@amoilanen
Created May 17, 2017 15:27
Show Gist options
  • Save amoilanen/5740cfd6af412a56c74cc34ddd8ed114 to your computer and use it in GitHub Desktop.
Save amoilanen/5740cfd6af412a56c74cc34ddd8ed114 to your computer and use it in GitHub Desktop.
Remove images, videos and backgrounds from the web page to leave only the text content
(function() {
function toArray(arrayLike) {
return [].slice.call(arrayLike);
}
function $(cssSelector) {
return toArray(document.querySelectorAll(cssSelector));
}
function hideImagesAndVideos() {
var allElementsToHide = $('img').concat($('video'));
allElementsToHide.forEach(function(element) {
element.style.display = 'none';
});
}
function disableBackgroundImages() {
$('body *').forEach(function(element) {
element.style.background = "none";
element.style.backgroundImage = "none";
});
}
function removeDistractions() {
hideImagesAndVideos();
disableBackgroundImages();
}
setInterval(removeDistractions, 500);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment