Masterani Placeholder

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

目前為 2014-10-28 提交的版本,檢視 最新版本

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

function ImageLoad(imgId)
{
    if (document.getElementById(imgId).naturalWidth < 2) // note: if image doesn't load naturalWidth == 1
        return false;
    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 (!ImageLoad(imgArray[i].id))
            imgArray[i].src = "http://oi62.tinypic.com/2zoer7s.jpg";
    }
    
}