Better Standalone Image

Make standalone image display better

  1. // ==UserScript==
  2. // @name Better Standalone Image
  3. // @version 0.1.1
  4. // @description Make standalone image display better
  5. // @license MIT
  6. // @author eight04 <eight04@gmail.com>
  7. // @homepageURL https://github.com/eight04/better-standalone-image
  8. // @supportURL https://github.com/eight04/better-standalone-image/issues
  9. // @namespace eight04.blogspot.com
  10. // @include *
  11. // @run-at document-start
  12. // @grant GM_getResourceURL
  13. // @grant GM_getResourceText
  14. // @grant GM_addStyle
  15. // @resource style https://rawgit.com/eight04/better-standalone-image/5097ca904ed82b7342afc68272e072d3218a96da/better-standalone-image.user.css
  16. // @compatible firefox Greasemonkey 3
  17. // @compatible chrome Tampermonkey
  18. // ==/UserScript==
  19.  
  20. (function() {
  21. if (!document.contentType.startsWith("image")) return;
  22. if (document.contentType == "image/svg+xml") {
  23. const s = document.documentElement.style;
  24. s.background = `
  25. linear-gradient(
  26. 45deg, rgba(0, 0, 0, .25), rgba(0, 0, 0, .25) 25%,
  27. transparent 25%, transparent 75%, rgba(0, 0, 0, .25) 75%
  28. ),
  29. linear-gradient(
  30. 45deg, rgba(0, 0, 0, .25), rgba(0, 0, 0, .25) 25%,
  31. transparent 25%, transparent 75%, rgba(0, 0, 0, .25) 75%
  32. ),
  33. #222
  34. `;
  35. s.backgroundPosition = "0 0, 8px 8px";
  36. s.backgroundSize = "16px 16px";
  37. s.position = "absolute";
  38. s.top = "0";
  39. s.right = "0";
  40. s.bottom = "0";
  41. s.left = "0";
  42. s.margin = "auto";
  43. s.boxShadow = "0 0 10px 10px rgba(0, 0, 0, .4)";
  44. } else {
  45. if (GM_info.scriptHandler == "Tampermonkey") {
  46. // Use GM_addStyle to bypass CSP in tampermonkey
  47. GM_addStyle(GM_getResourceText("style"));
  48. } else {
  49. // Use extension protocol to bypass CSP in greasemonkey
  50. const link = document.createElement("link");
  51. link.href = GM_getResourceURL("style");
  52. link.rel = "stylesheet";
  53. document.documentElement.appendChild(link);
  54. }
  55. }
  56. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址