Greasy Fork

Greasy Fork is available in English.

Masterani Placeholder

Loads badass Luffy as a placeholder if original image doesn't load (under recent anime)

当前为 2014-10-28 提交的版本,查看 最新版本

// ==UserScript==
// @name         Masterani Placeholder
// @description  Loads badass Luffy as a placeholder if original image doesn't load (under recent anime)
// @version      1.0
// @namespace    http://greasyfork.icu/users/5141
// @license      WTFPL v2
// @include	 http://www.masterani.me/
// ==/UserScript==

function ImageNotLoad(imgId)
{
    if (document.getElementById(imgId).naturalWidth === 1) // note: if image doesn't load naturalWidth === 1
        return true;
}

window.onload = function SetImgId()
{
    var imgArray = document.getElementsByClassName("lazy");
    for (var i = 0; i < imgArray.length; i++)
    {
        imgArray[i].id = "img" + i;
        if (ImageNotLoad(imgArray[i].id))
            imgArray[i].src = "http://oi62.tinypic.com/2zoer7s.jpg"; //set your prefered pic
    } 
}