derpibooru- Force medium thumbnails

2/10/2023 Forces use of medium size thumbnails by removing the first from images' srcset property and changing src.

// ==UserScript==
// @name        derpibooru- Force medium thumbnails
// @namespace   Violentmonkey Scripts
// @match       https://derpibooru.org/*
// @grant       none
// @version     1.3
// @license     MIT
// @author      Saphkey
// @description 2/10/2023 Forces use of medium size thumbnails by removing the first from images' srcset property and changing src.
// ==/UserScript==


(function() {
		console.log("ForceMediumThumbnails started.")
    var imgEls = document.getElementsByTagName('img');

    for(let i=0; i < imgEls.length; i++){try{
        let imgEl = imgEls[i];

        let srcSet = imgEl.srcset.split(', ');
        if(srcSet.length>1){
          imgEl.style.display = "none";

          imgEl.srcset = srcSet[1].split(' ')[0];
          imgEl.src = imgEl.srcset;

          imgEl.onload = ()=>{
            imgEl.style.display = "inline"
          }
        }
			}catch(e){
				console.error("error in forceMediumThumbnails:", e);
			}
    }
})();