汉典诗词-打印唐诗宋词

打印时只展示唐诗宋词内容并调整字体大小

  1. // ==UserScript==
  2. // @name 汉典诗词-打印唐诗宋词
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description 打印时只展示唐诗宋词内容并调整字体大小
  6. // @author You
  7. // @match http://sc.zdic.net/*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=zdic.net
  9. // @grant none
  10. // @license mit
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15. const style = document.createElement('style')
  16. const head = document.head || document.getElementsByTagName('head')[0]
  17. style.type = 'text/css'
  18. const cssText = `
  19. @media print {
  20. body {
  21. visibility: hidden;
  22. }
  23. #mbnr {
  24. visibility: visible;
  25. }
  26. #mbnr {
  27. position: fixed;
  28. width: 100%;
  29. height: 100%;
  30. top: 0;
  31. left: 0;
  32. margin: 0;
  33. padding: 0;
  34. display: flex;
  35. flex-direction: column;
  36. justify-content: center;
  37. }
  38. #mbnr > * {
  39. display: none;
  40. }
  41. #mbnr #scbt,
  42. #mbnr #sc1 {
  43. display: block;
  44. }
  45. #scbt, #scxx, #scnr, #scnr p {
  46. line-height: 2;
  47. }
  48. #scbt {
  49. font-size: 40px;
  50. }
  51. #scxx {
  52. font-size: 30px;
  53. }
  54. #scnr, #scnr p {
  55. font-size: 36px;
  56. }
  57. }
  58. `
  59. const textNode = document.createTextNode(cssText);
  60. style.appendChild(textNode);
  61. head.appendChild(style); //把创建的style元素插入到head中
  62. })();

QingJ © 2025

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