Show and reload broken images

The name explained it

目前为 2014-05-11 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Show and reload broken images
  3. // @description The name explained it
  4. // @namespace eight04.blogspot.com
  5. // @include http://*
  6. // @include https://*
  7. // @version 1.2
  8. // @grant GM_addStyle
  9. // ==/UserScript==
  10.  
  11. (function(){
  12. GM_addStyle(
  13. // "img:-moz-broken{-moz-force-broken-image-icon:1;}"
  14. "img{-moz-force-broken-image-icon:1;}"
  15. );
  16. var imgs=document.images;
  17.  
  18. function checkBroken(img){
  19. // return window.getComputedStyle(img).MozForceBrokenImageIcon * 1;
  20. return !img.complete || !img.naturalWidth;
  21. }
  22.  
  23. function load(d){
  24. d.src += "#";
  25. }
  26.  
  27. function reloadImg(){
  28. var len = imgs.length
  29. for(var i=0;i< len;i++)
  30. if(checkBroken(imgs[i]) && imgs[i].src)
  31. load(imgs[i]);
  32. }
  33.  
  34. function getKey(e){
  35. if(e.keyCode==82 && e.altKey)
  36. reloadImg();
  37. }
  38.  
  39. document.addEventListener("keyup",getKey,false);
  40.  
  41. })();