AIGC春联

A AIGC couplet

  1. // ==UserScript==
  2. // @license MIT
  3. // @name AIGC春联
  4. // @namespace http://tampermonkey.net/
  5. // @version 2024-01-27
  6. // @description A AIGC couplet
  7. // @author Sincenir
  8. // @match *://*/*
  9. // @icon https://www.google.com/s2/favicons?sz=64&domain=undefined.
  10. // @grant GM_addStyle
  11. // @require https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.0.0/crypto-js.min.js
  12. // ==/UserScript==
  13. (function () {
  14. "use strict";
  15.  
  16. GM_addStyle(`@keyframes horizontal-expand {
  17. 0% {
  18. transform: scaleX(0) translateX(-50%);
  19. }
  20. 100% {
  21. transform: scaleX(1) translateX(-50%);
  22. }
  23. }
  24. @keyframes vertical-expand {
  25. 0% {
  26. transform: scaleY(0) translateY(-50%);
  27. }
  28. 100% {
  29. transform: scaleY(1) translateY(-50%);
  30. }
  31. }
  32.  
  33. @keyframes spin {
  34. from {
  35. transform: rotate(0deg);
  36. }
  37. to {
  38. transform: rotate(360deg);
  39. }
  40. }
  41. @keyframes hide {
  42. 0% {
  43. opacity: 1;
  44. }
  45. 30% {
  46. opacity: 0;
  47. }
  48. 100% {
  49. opacity: 0;
  50. }
  51. }
  52.  
  53. .couplet-container {
  54. position: fixed;
  55. top: 0;
  56. left: 0;
  57. width: 100vw;
  58. height: 100vh;
  59. pointer-events: none;
  60. font-family: "楷体", "宋体", "Microsoft YaHei", sans-serif;
  61. font-size: 32px;
  62. font-weight: 700;
  63. color: #fec401;
  64. z-index: 1000000000;
  65. }
  66. .top {
  67. position: absolute;
  68. top: 5%;
  69. left: 50%;
  70. transform: translateX(-50%);
  71. transform-origin: left;
  72. width: 200px;
  73. height: auto;
  74. padding: 16px 24px;
  75. background-color: #ca3a2a;
  76. text-align: center;
  77. overflow: hidden;
  78. white-space: nowrap;
  79. animation: horizontal-expand 1s ease-in-out;
  80. box-shadow: 0 0 0 6px #ff664d;
  81. border-radius: 8px;
  82. }
  83. .top::before {
  84. content: "";
  85. position: absolute;
  86. top: 10px;
  87. left: 16px;
  88. right: 16px;
  89. bottom: 10px;
  90. border: 4px solid #f3dab8;
  91. border-radius: 8px;
  92. }
  93. .couplet-all {
  94. position: absolute;
  95. top: 50%;
  96. transform: translateY(-50%);
  97. width: auto;
  98. height: auto;
  99. padding: 32px 24px;
  100. background-color: #ca3a2a;
  101. writing-mode: vertical-rl;
  102. text-align: center;
  103. overflow: hidden;
  104. white-space: nowrap;
  105. animation: vertical-expand 1s ease-in-out;
  106. box-shadow: 0 0 0 6px #ff664d;
  107. border-radius: 8px;
  108. }
  109.  
  110. .couplet-all::before {
  111. content: "";
  112. position: absolute;
  113. top: 16px;
  114. left: 10px;
  115. right: 10px;
  116. bottom: 16px;
  117. border: 4px solid #f3dab8;
  118. border-radius: 8px;
  119. }
  120.  
  121. .couplet-up {
  122. transform-origin: top;
  123. right: 5%;
  124. }
  125. .couplet-down {
  126. transform-origin: top;
  127. left: 5%;
  128. }
  129. .couplet-fu {
  130. width: 100%;
  131. height: 100%;
  132. display: flex;
  133. justify-content: center;
  134. align-items: center;
  135. animation: spin 1s ease;
  136. }
  137.  
  138. .hide {
  139. animation: hide 3s ease-in-out;
  140. }`);
  141.  
  142. const showTime = 10000;
  143. const coupletList = [
  144. {
  145. up: "龙飞凤舞春盈四海",
  146. down: "岁稔年丰福满九州",
  147. top: "四海同春",
  148. },
  149. {
  150. up: "龙骧盛世财源广进",
  151. down: "岁稔新春福运亨通",
  152. top: "盛世财源",
  153. },
  154. {
  155. up: "龙舞云天开新运财如泉涌",
  156. down: "春回大地展宏图福满人间",
  157. top: "龙运亨通",
  158. },
  159. {
  160. up: "龙年百福临喜气祥和户户",
  161. down: "春风万里送欢歌笑语声声",
  162. top: "迎春接福",
  163. },
  164. {
  165. up: "龙腾盛世展宏图业兴财旺",
  166. down: "春满神州添锦绣福寿安康",
  167. top: "大展鸿图",
  168. },
  169. {
  170. up: "龙年百福临喜气祥和户户",
  171. down: "春风万里送欢歌笑语声声",
  172. top: "迎春接福",
  173. },
  174. {
  175. up: "龙征万里",
  176. down: "福满乾坤",
  177. top: "万里乾坤福",
  178. },
  179. ];
  180.  
  181. function createCoupletContainer() {
  182. const container = document.createElement("div");
  183. container.className = "couplet-container";
  184. return container;
  185. }
  186.  
  187. function createTop(str) {
  188. const topEl = document.createElement("div");
  189. topEl.innerHTML = str;
  190. topEl.className = "top";
  191. return topEl;
  192. }
  193.  
  194. function createUp(str) {
  195. const upEl = document.createElement("div");
  196. upEl.className = "couplet-all couplet-up";
  197.  
  198. upEl.innerHTML = str;
  199. return upEl;
  200. }
  201.  
  202. function createDown(str) {
  203. const down = document.createElement("div");
  204. down.className = "couplet-all couplet-down";
  205.  
  206. down.innerHTML = str;
  207. return down;
  208. }
  209.  
  210. function createFu() {
  211. const fu = document.createElement("div");
  212. fu.className = "couplet-fu";
  213. fu.innerHTML =
  214. '<svg t="1706247528897" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2446" width="200" height="200"><path d="M457.665918 982.912037L41.187933 566.334082c-29.891243-29.891243-29.891243-78.776921 0-108.468222L457.665918 41.387875c29.891243-29.891243 78.67695-29.891243 108.468222 0L982.712096 457.86586c29.891243 29.891243 29.891243 78.776921 0 108.468222L566.334082 983.012008c-29.891243 29.791272-78.776921 29.791272-108.668164-0.099971z m0 0" fill="#CA3A2A" p-id="2447"></path><path d="M512.049985 1024c-24.392854 0-48.885678-9.297276-67.48023-27.891829L28.09177 579.630186c-37.189105-37.189105-37.189105-97.671385 0-134.86049L444.569755 28.09177c37.189105-37.189105 97.671385-37.189105 134.86049 0l416.477985 416.477985c37.189105 37.189105 37.189105 97.671385 0 134.86049L579.430245 996.108171c-18.594552 18.594552-42.987406 27.891829-67.38026 27.891829z m0-986.510983c-14.895636 0-29.791272 5.698331-41.187933 16.995021L54.384067 470.962023c-22.693352 22.693352-22.693352 59.582544 0 82.175925L470.862052 969.715904c22.693352 22.693352 59.582544 22.693352 82.175925 0l416.477985-416.477985c22.693352-22.693352 22.693352-59.582544 0-82.175925L553.037977 54.484038c-11.29669-11.396661-26.192326-16.995021-40.987992-16.995021z m0 0" fill="#CA3A2A" p-id="2448"></path><path d="M864.346773 475.060822L549.039149 159.653227c-9.79713-9.8971-22.993264-15.295519-36.989164-15.295519s-27.092063 5.398418-36.989163 15.295519L159.553256 475.060822c-20.394025 20.394025-20.394025 53.684272 0 74.178268L475.060822 864.746656c10.097042 10.197013 23.693059 15.295519 36.989163 15.295519 13.396075 0 26.892121-5.098506 36.989164-15.295519l315.307624-315.707507c9.8971-9.79713 15.295519-22.993264 15.295519-36.989164s-5.398418-27.192034-15.295519-36.989163z m-12.996192 45.486674l-330.903056 330.903056c-4.398711 4.598653-12.096456 4.598653-16.695109 0l-331.003026-330.903056c-4.598653-4.498682-4.598653-12.096456 0-16.695109l331.003026-331.003026c2.999121-2.999121 6.498096-3.399004 8.39754-3.399005 1.899444 0 5.398418 0.399883 8.39754 3.399005l330.903056 331.003026c2.999121 2.999121 3.399004 6.498096 3.399004 8.39754-0.199941 1.799473-0.599824 5.298448-3.498975 8.297569z m0 0" fill="#F3DAB8" p-id="2449"></path><path d="M668.60412 596.425266H562.835107c-7.297862 0-13.9959-4.298741-16.995021-10.896808-2.999121-6.598067-1.899444-14.395782 2.899151-19.894171L670.203651 425.875232c6.798008-7.797716 18.494582-8.597481 26.292297-1.799473 7.797716 6.698038 8.597481 18.494582 1.899444 26.292297l-94.672264 108.968076h64.980963c10.197013 0 18.594552 8.39754 18.594552 18.594552 0.099971 10.197013-8.297569 18.494582-18.694523 18.494582z m-33.190276 51.584887l-28.09177-33.990042" fill="#FEC401" p-id="2450"></path><path d="M635.413844 666.604706c-5.298448 0-10.696866-2.299326-14.295812-6.698038l-27.991799-33.890071c-6.498096-7.897686-5.498389-19.69423 2.399297-26.192327s19.69423-5.498389 26.192326 2.399297l27.991799 33.890072c6.498096 7.897686 5.498389 19.69423-2.399297 26.192326-3.598946 2.899151-7.697745 4.298741-11.896514 4.298741z m-22.793323-135.060432c-10.197013 0-18.594552-8.39754-18.594552-18.594552V376.189788c0-10.197013 8.39754-18.594552 18.594552-18.594552 10.197013 0 18.594552 8.39754 18.594553 18.594552v136.759934c0 10.197013-8.39754 18.594552-18.594553 18.594552z m0 0" fill="#FEC401" p-id="2451"></path><path d="M582.829249 504.052328c-4.998536 0-9.997071-1.999414-13.695987-6.098213l-32.690423-35.589573c-6.99795-7.597774-6.398126-19.294347 1.199649-26.292298 7.597774-6.99795 19.294347-6.398126 26.292297 1.199649l32.690422 35.589573c6.99795 7.597774 6.398126 19.294347-1.199648 26.292298-3.598946 3.199063-8.197598 4.898565-12.59631 4.898564z m-94.772234 162.552378H351.896905c-10.197013 0-18.594552-8.39754-18.594552-18.594553 0-10.197013 8.39754-18.594552 18.594552-18.594552h136.16011c10.197013 0 18.594552 8.39754 18.594552 18.594552 0 10.197013-8.297569 18.594552-18.594552 18.594553z m-19.294348-48.485796h-97.571414c-12.196427 0-22.093527-9.8971-22.093528-22.093527V549.838914c0-12.196427 9.8971-22.093527 22.093528-22.093527h97.571414c12.196427 0 22.093527 9.8971 22.093527 22.093527v46.186469c0.099971 12.196427-9.8971 22.093527-22.093527 22.093527zM386.28683 580.829835h67.48023v-15.895343h-67.48023V580.829835z m84.175339-75.577858h-100.970419c-26.69218 0-48.485795-21.693644-48.485795-48.485795v-49.18559c0-26.69218 21.793615-48.485795 48.485795-48.485796h100.970419c26.69218 0 48.485795 21.793615 48.485795 48.485796V456.866152c0 26.69218-21.693644 48.385824-48.485795 48.385825zM369.591721 396.383872c-6.198184 0-11.29669 5.098506-11.29669 11.29669V456.866152c0 6.198184 5.098506 11.29669 11.29669 11.296691h100.970419c6.198184 0 11.29669-5.098506 11.29669-11.296691v-49.18559c0-6.198184-5.098506-11.29669-11.29669-11.29669h-100.970419z m0 0" fill="#FEC401" p-id="2452"></path><path d="M482.858538 450.767939H356.695499c-10.197013 0-18.594552-8.39754-18.594552-18.594552 0-10.197013 8.39754-18.594552 18.594552-18.594553H482.858538c10.197013 0 18.594552 8.39754 18.594552 18.594553 0 10.197013-8.39754 18.594552-18.594552 18.594552z m0 0" fill="#FEC401" p-id="2453"></path><path d="M419.677048 496.354584c-10.197013 0-18.594552-8.39754-18.594553-18.594553v-92.972762c0-10.197013 8.39754-18.594552 18.594553-18.594552 10.197013 0 18.594552 8.39754 18.594552 18.594552v92.972762c0 10.197013-8.197598 18.594552-18.594552 18.594553z m0 0" fill="#FEC401" p-id="2454"></path><path d="M512.049985 1024c-24.392854 0-48.885678-9.297276-67.48023-27.891829L28.09177 579.630186c-37.189105-37.189105-37.189105-97.671385 0-134.86049L444.569755 28.09177c37.189105-37.189105 97.671385-37.189105 134.86049 0l416.477985 416.477985c37.189105 37.189105 37.189105 97.671385 0 134.86049L579.430245 996.108171c-18.594552 18.594552-42.987406 27.891829-67.38026 27.891829z m0-986.510983c-14.895636 0-29.791272 5.698331-41.187933 16.995021L54.384067 470.962023c-22.693352 22.693352-22.693352 59.582544 0 82.175925L470.862052 969.715904c22.693352 22.693352 59.582544 22.693352 82.175925 0l416.477985-416.477985c22.693352-22.693352 22.693352-59.582544 0-82.175925L553.037977 54.484038c-11.29669-11.396661-26.192326-16.995021-40.987992-16.995021z m0 0" fill="#FF664D" p-id="2455"></path></svg>';
  215. return fu;
  216. }
  217.  
  218. const coupletContainer = createCoupletContainer();
  219.  
  220. function getRandomInt(min, max) {
  221. min = Math.ceil(min);
  222. max = Math.floor(max);
  223. return Math.floor(Math.random() * (max - min + 1)) + min;
  224. }
  225.  
  226. const c = coupletList[getRandomInt(0, coupletList.length - 1)];
  227. const top = createTop(c.top);
  228. const up = createUp(c.up);
  229. const down = createDown(c.down);
  230. const fu = createFu();
  231. coupletContainer.append(top);
  232. coupletContainer.append(up);
  233. coupletContainer.append(down);
  234. coupletContainer.append(fu);
  235. document.body.append(coupletContainer);
  236.  
  237. setTimeout(() => {
  238. document.querySelector(".couplet-container").className =
  239. "couplet-container hide";
  240. setTimeout(() => {
  241. document.querySelector(".couplet-container").remove();
  242. }, 1000);
  243. }, showTime);
  244.  
  245. document.addEventListener("keydown", (e) => {
  246. if (e.key !== "Escape") return;
  247. document.querySelector(".couplet-container").className =
  248. "couplet-container hide";
  249. setTimeout(() => {
  250. document.querySelector(".couplet-container").remove();
  251. }, 1000);
  252. });
  253. })();

QingJ © 2025

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