function initializeBlur(e, f) {
var blur = (sessionStorage.getItem('blur') == "true");
images = $('.mw-file-element');
if(blur){
images.css('filter', 'blur(30px)');
} else {
images.css('filter', 'blur(0px)');
}
}
function switchBlur(e) {
var blur = (sessionStorage.getItem('blur') == "true");
images = $('.mw-file-element');
if(blur){
images.css('filter', 'blur(0px)');
$('#pt-blur').find("span").html('Blur images');
blur = false;
} else {
images.css('filter', 'blur(30px)');
$('#pt-blur').find("span").html('Show images');
blur = true;
}
sessionStorage.setItem('blur', (blur?"true":"false"));
}
function buildMenu() {
mw.util.addPortlet('p-imgs', 'Images', '#p-interaction');
mw.util.addPortletLink ( 'p-imgs', '#', 'Show images', 'pt-blur', 'Show/blur images' );
$('#pt-blur').click(switchBlur);
initializeBlur(null);
const observer = new MutationObserver(initializeBlur);
const config = { attributes: true, childList: true, subtree: true };
observer.observe($('#content'), config);
}
$(document).ready(buildMenu);