readimage

已经看过的图片显示红框

  1. // ==UserScript==
  2. // @name readimage
  3. // @namespace taoww
  4. // @include http://*
  5. // @include https://*
  6. // @include ftp://*
  7. // @exclude *://tieba.baidu.com/*
  8. // @exclude *://hi.baidu.com/*
  9. // @exclude *://blog.sina.com.cn/*
  10. // @exclude *://*.blog.sina.com.cn/*
  11. // @exclude *://www.51.la/*
  12. // @exclude *://bbs.aicbbs.com/*
  13. // @version 1.1
  14. // @description 已经看过的图片显示红框
  15. // @grant GM_addStyle
  16. // ==/UserScript==
  17.  
  18. GM_addStyle("a img { border: 7px solid white; }");
  19. GM_addStyle("a:visited img { border-color: red !important; }");
  20.  
  21. document.body.addEventListener("click", function(event) {
  22. var t = event.target;
  23. if (t.tagName === "IMG") {
  24. var link = null;
  25. if (t.parentNode.tagName === "A") {
  26. link = t.parentNode;
  27. } else if (t.parentNode.tagName != "A" &&
  28. t.parentNode.children.length === 1 &&
  29. t.parentNode.parentNode.tagName === "A") {
  30. link = t.parentNode.parentNode;
  31. }
  32. if (link && link.target !== "_blank" && link.href) {
  33. var f = document.createElement("iframe");
  34. f.style.display = "none";
  35. f.src = link.href;
  36. document.body.appendChild(f);
  37. }
  38. }
  39. }, false);