Show and reload broken images

The name explained it

目前为 2016-04-04 提交的版本。查看 最新版本

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