ImageViewer

浏览器图片查看效果增强 for Chrome/Edge/Firefox

当前为 2021-07-13 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name ImageViewer
  3. // @version 1.0.8
  4. // @description 浏览器图片查看效果增强 for Chrome/Edge/Firefox
  5. // @author Jack.Chan (971546@qq.com)
  6. // @namespace http://fulicat.com
  7. // @url https://gf.qytechs.cn/zh-CN/scripts/429054-imageviewer
  8. // @match *://*/*
  9. // @grant none
  10. // @run-at document-start
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15. if (document.contentType.startsWith('image/')) {
  16. var doc = document.body || document.documentElement;
  17. var docTagName = (function(tag){
  18. var tagName = tag && tag.tagName.toLowerCase();
  19. if (tagName) {
  20. if (tagName == 'svg') {
  21. return tagName;
  22. }
  23. if (tagName == 'body' && tag.children && tag.children.length) {
  24. tagName = tag.children[0].tagName.toLowerCase();
  25. if (tagName == 'img') {
  26. return tagName;
  27. }
  28. }
  29. }
  30. })(doc);
  31. var isViewerMode = docTagName == 'svg' || docTagName == 'img';
  32. if (isViewerMode) {
  33. if (document.head) {
  34. var style = document.createElement('style');
  35. style.setAttribute('type', 'text/css');
  36. style.innerHTML = `img{position: static !important;background: none !important;background-color: transparent !important;}`;
  37. document.head.appendChild(style);
  38. }
  39. doc.style.backgroundImage = 'url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI2NCIgaGVpZ2h0PSI2NCIgdmlld0JveD0iMCAwIDY0IDY0Ij4KICA8ZGVmcz4KICAgIDxzdHlsZT4KICAgICAgLmNscy0xIHsKICAgICAgICBmaWxsOiAjMzAzMDMwOwogICAgICB9CgogICAgICAuY2xzLTIgewogICAgICAgIGZpbGw6ICMyMDIwMjA7CiAgICAgIH0KICAgIDwvc3R5bGU+CiAgPC9kZWZzPgogIDxyZWN0IGlkPSJsdCIgY2xhc3M9ImNscy0xIiB3aWR0aD0iMzIiIGhlaWdodD0iMzIiLz4KICA8cmVjdCBpZD0icmIiIGNsYXNzPSJjbHMtMSIgeD0iMzIiIHk9IjMyIiB3aWR0aD0iMzIiIGhlaWdodD0iMzIiLz4KICA8cmVjdCBpZD0ibGIiIGNsYXNzPSJjbHMtMiIgeT0iMzIiIHdpZHRoPSIzMiIgaGVpZ2h0PSIzMiIvPgogIDxyZWN0IGlkPSJydCIgY2xhc3M9ImNscy0yIiB4PSIzMiIgd2lkdGg9IjMyIiBoZWlnaHQ9IjMyIi8+Cjwvc3ZnPgo=)';
  40. doc.style.backgroundAttachment = 'fixed';
  41. doc.style.boxSizing = 'border-box';
  42. doc.style.position = 'absolute';
  43. doc.style.top = '50%';
  44. doc.style.left = '50%';
  45. doc.style.transform = 'translate(-50%, -50%)';
  46. if (docTagName == 'svg') {
  47. doc.style.padding = '10px';
  48. doc.style.width = 'auto';
  49. doc.style.height = 'auto';
  50. doc.style.maxWidth = '100%';
  51. doc.style.maxHeight = '100%';
  52. }
  53. }
  54. }
  55. })();

QingJ © 2025

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