Created
May 17, 2017 15:27
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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