index.html 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724
  1. <!DOCTYPE html>
  2. <html lang="zh-Hans-CN">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <meta name="viewport" content="width=350px, initial-scale=1.0" />
  6. <title>自己搜去</title>
  7. <meta
  8. name="description"
  9. content="给不愿意或不会自己搜索的人类,快速生成教他们搜索页面的工具"
  10. />
  11. <meta name="repo" content="search-it-yourself" />
  12. <meta name="author" content="wasteest, pj568" />
  13. <meta name="license" content="cc by-sa 4.0" />
  14. <link
  15. rel="icon"
  16. type="image/svg+xml"
  17. href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Ctext y='.9em' font-size='90'%3E🔍%3C/text%3E%3C/svg%3E"
  18. />
  19. <style>
  20. :root,
  21. html {
  22. padding: 0;
  23. margin: 0;
  24. height: 100%;
  25. }
  26. body {
  27. margin: 0;
  28. padding: 40px 20px;
  29. font-family: Arial, sans-serif;
  30. background-color: #e6e6e6;
  31. color: #333333;
  32. }
  33. h1 {
  34. text-align: center;
  35. font-weight: bold;
  36. color: #333333;
  37. }
  38. .search-container {
  39. max-width: 600px;
  40. margin: 20vh auto 0 auto;
  41. text-align: center;
  42. }
  43. .search-form {
  44. display: flex;
  45. gap: 10px;
  46. justify-content: center;
  47. align-items: center;
  48. }
  49. .search-input {
  50. padding: 12px;
  51. font-size: 16px;
  52. border: none;
  53. background: #f5f5f5;
  54. width: 300px;
  55. }
  56. .search-button {
  57. padding: 12px 24px;
  58. font-size: 16px;
  59. border: none;
  60. background: #888;
  61. color: white;
  62. cursor: pointer;
  63. svg {
  64. width: 16px;
  65. height: 16px;
  66. }
  67. }
  68. .search-button:hover {
  69. background: #555;
  70. }
  71. /* 深色模式支持 */
  72. @media (prefers-color-scheme: dark) {
  73. :root,
  74. html,
  75. body {
  76. background-color: #212121;
  77. color: #f1f1f1;
  78. }
  79. h1 {
  80. color: #f1f1f1;
  81. }
  82. .search-input {
  83. background: #333333;
  84. color: #f1f1f1;
  85. border: 1px solid #555555;
  86. }
  87. .search-button {
  88. background: #4a90e2;
  89. color: #f1f1f1;
  90. border: 1px solid #357abd;
  91. }
  92. .search-button:hover {
  93. background: #357abd;
  94. }
  95. }
  96. /* 搜索结果样式 */
  97. .search-result {
  98. margin-top: 30px;
  99. text-align: center;
  100. }
  101. .result-code-block {
  102. display: inline-block;
  103. background: #f8f9fa;
  104. border: 1px solid #e9ecef;
  105. padding: 15px;
  106. margin: 10px 0;
  107. font-family: "Courier New", monospace;
  108. font-size: 14px;
  109. color: #495057;
  110. cursor: pointer;
  111. transition: all 0.2s ease;
  112. max-width: 100%;
  113. word-break: break-all;
  114. }
  115. .result-code-block:hover {
  116. background: #e9ecef;
  117. border-color: #adb5bd;
  118. }
  119. .result-code-block:active {
  120. background: #dee2e6;
  121. transform: scale(0.98);
  122. }
  123. .copy-notification {
  124. position: fixed;
  125. top: 20px;
  126. right: 20px;
  127. background: #1f512b;
  128. color: white;
  129. padding: 10px 20px;
  130. font-size: 14px;
  131. opacity: 0;
  132. transition: opacity 0.3s ease;
  133. z-index: 1000;
  134. }
  135. .copy-notification.show {
  136. opacity: 1;
  137. }
  138. /* 深色模式下的搜索结果样式 */
  139. @media (prefers-color-scheme: dark) {
  140. .result-code-block {
  141. background: #2d3748;
  142. border-color: #4a5568;
  143. color: #e2e8f0;
  144. }
  145. .result-code-block:hover {
  146. background: #4a5568;
  147. border-color: #718096;
  148. }
  149. .result-code-block:active {
  150. background: #718096;
  151. }
  152. }
  153. /* 有序列表样式 */
  154. .list-div {
  155. display: none;
  156. background: #12121211;
  157. max-width: 600px;
  158. margin: 40px auto 0;
  159. padding: 1rem;
  160. position: relative;
  161. a {
  162. text-decoration: underline;
  163. cursor: pointer;
  164. position: absolute;
  165. top: 1rem;
  166. right: 1rem;
  167. }
  168. }
  169. .list-div li {
  170. margin-bottom: 1rem;
  171. color: inherit;
  172. }
  173. .list-div li:last-child {
  174. margin-bottom: 0;
  175. }
  176. .list-div li p {
  177. margin: 0;
  178. padding: 0;
  179. }
  180. /* 深色模式下的有序列表样式 */
  181. @media (prefers-color-scheme: dark) {
  182. .list-div {
  183. background: #e9ecef11;
  184. }
  185. .list-div li {
  186. color: #f1f1f1;
  187. }
  188. }
  189. .cursor {
  190. color: #333333;
  191. display: none;
  192. top: -24px;
  193. left: -24px;
  194. position: fixed;
  195. width: 24px;
  196. height: 24px;
  197. z-index: 1000;
  198. pointer-events: none;
  199. transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  200. filter: drop-shadow(0 0 0.3rem white);
  201. }
  202. .cursor.visible {
  203. display: block;
  204. }
  205. .cursor.click {
  206. animation: clickPulse 0.3s ease-in-out;
  207. }
  208. @keyframes clickPulse {
  209. 0% {
  210. transform: scale(1);
  211. }
  212. 50% {
  213. transform: scale(1.2);
  214. }
  215. 100% {
  216. transform: scale(1);
  217. }
  218. }
  219. /* 输入框焦点状态下的光标 */
  220. .search-input.focused {
  221. box-shadow: 0 0 0 2px #007bff;
  222. }
  223. /* 按钮点击效果 */
  224. .search-button.clicked {
  225. transform: scale(0.95);
  226. transition: transform 0.1s ease;
  227. }
  228. /* 深色模式下的光标 */
  229. @media (prefers-color-scheme: dark) {
  230. .cursor {
  231. color: #e9ecef;
  232. filter: drop-shadow(0 0 0.3rem black);
  233. }
  234. }
  235. </style>
  236. </head>
  237. <body>
  238. <div class="search-container">
  239. <h1>自己搜去</h1>
  240. <form class="search-form" id="searchForm" action="javascript:void(0);">
  241. <input
  242. type="text"
  243. class="search-input"
  244. id="searchInput"
  245. name="q"
  246. placeholder="请输入搜索内容"
  247. autofocus
  248. />
  249. <button type="submit" class="search-button">
  250. <!-- MIT Copyright (c) 2018-2025 Tabler -->
  251. <svg
  252. xmlns="http://www.w3.org/2000/svg"
  253. width="24"
  254. height="24"
  255. viewBox="0 0 24 24"
  256. fill="none"
  257. stroke="currentColor"
  258. stroke-width="2"
  259. stroke-linecap="round"
  260. stroke-linejoin="round"
  261. class="icon icon-tabler icons-tabler-outline icon-tabler-search"
  262. >
  263. <path stroke="none" d="M0 0h24v24H0z" fill="none" />
  264. <path d="M10 10m-7 0a7 7 0 1 0 14 0a7 7 0 1 0 -14 0" />
  265. <path d="M21 21l-6 -6" />
  266. </svg>
  267. </button>
  268. </form>
  269. <!-- 搜索结果显示区域 -->
  270. <div class="search-result" id="searchResult" style="display: none">
  271. <div class="result-code-block" id="resultLink" title="点击复制链接">
  272. <!-- 搜索链接将在这里显示 -->
  273. </div>
  274. </div>
  275. </div>
  276. <!-- 复制成功提示 -->
  277. <div class="copy-notification" id="copyNotification">
  278. 链接已复制到剪贴板!
  279. </div>
  280. <div class="list-div">
  281. <ol>
  282. <li>
  283. <p>输入要搜索的内容;</p>
  284. </li>
  285. <li>
  286. <p>点击搜索按钮;</p>
  287. </li>
  288. <li>
  289. <p>将生成的链接复制到剪贴板,发给不愿意或不会自己搜索的人类。</p>
  290. </li>
  291. </ol>
  292. <a
  293. onclick="javascript:window.open('?q=Z2l0IHJlcG8gc2VhcmNoLWl0LXlvdXJzZWxmIHBqNTY4')"
  294. >项目源码</a
  295. >
  296. </div>
  297. <div class="cursor">
  298. <!-- MIT Copyright (c) 2018-2025 Tabler -->
  299. <svg
  300. xmlns="http://www.w3.org/2000/svg"
  301. width="24"
  302. height="24"
  303. viewBox="0 0 24 24"
  304. fill="none"
  305. stroke="currentColor"
  306. stroke-width="2"
  307. stroke-linecap="round"
  308. stroke-linejoin="round"
  309. class="icon icon-tabler icons-tabler-outline icon-tabler-pointer"
  310. >
  311. <path stroke="none" d="M0 0h24v24H0z" fill="none" />
  312. <path
  313. d="M7.904 17.563a1.2 1.2 0 0 0 2.228 .308l2.09 -3.093l4.907 4.907a1.067 1.067 0 0 0 1.509 0l1.047 -1.047a1.067 1.067 0 0 0 0 -1.509l-4.907 -4.907l3.113 -2.09a1.2 1.2 0 0 0 -.309 -2.228l-13.582 -3.904l3.904 13.563z"
  314. />
  315. </svg>
  316. </div>
  317. <script>
  318. // 语言检测和翻译功能
  319. function detectLanguage() {
  320. // 获取浏览器语言偏好
  321. const browserLang =
  322. navigator.language || navigator.userLanguage || "zh-CN";
  323. // 检查是否为英语(包含 en 开头的语言代码)
  324. const isEnglish = browserLang.startsWith("en");
  325. // 翻译映射
  326. const translations = {
  327. title: "Search It Yourself",
  328. mainTitle: "Search It Yourself",
  329. inputPlaceholder: "Enter search content",
  330. copyNotification: "Link copied to clipboard!",
  331. emptyInputAlert: "Please enter search content",
  332. instruction1: "Enter the content to search;",
  333. instruction2: "Click the search button;",
  334. instruction3:
  335. "Copy the generated link to clipboard and send it to people who are unwilling or unable to search themselves.",
  336. projectSource: "Project Source Code",
  337. };
  338. // 如果是英语,则进行翻译
  339. if (isEnglish) {
  340. // 翻译页面标题
  341. document.title = translations.title;
  342. // 翻译主标题
  343. const mainTitle = document.querySelector("h1");
  344. if (mainTitle) {
  345. mainTitle.textContent = translations.mainTitle;
  346. }
  347. // 翻译输入框占位符
  348. const searchInput = document.getElementById("searchInput");
  349. if (searchInput) {
  350. searchInput.placeholder = translations.inputPlaceholder;
  351. }
  352. // 翻译复制成功提示
  353. const copyNotification = document.getElementById("copyNotification");
  354. if (copyNotification) {
  355. copyNotification.textContent = translations.copyNotification;
  356. }
  357. // 翻译使用说明
  358. const listDiv = document.querySelector(".list-div");
  359. if (listDiv) {
  360. const instructions = listDiv.querySelectorAll("p");
  361. if (instructions.length >= 3) {
  362. instructions[0].textContent = translations.instruction1;
  363. instructions[1].textContent = translations.instruction2;
  364. instructions[2].textContent = translations.instruction3;
  365. }
  366. // 翻译项目源码链接
  367. const projectSourceLink = listDiv.querySelector("a");
  368. if (projectSourceLink) {
  369. projectSourceLink.textContent = translations.projectSource;
  370. }
  371. }
  372. }
  373. return isEnglish;
  374. }
  375. // 初始化时执行语言检测
  376. document.addEventListener("DOMContentLoaded", function () {
  377. detectLanguage();
  378. });
  379. // 获取页面元素
  380. const searchForm = document.getElementById("searchForm");
  381. const searchInput = document.getElementById("searchInput");
  382. const searchResult = document.getElementById("searchResult");
  383. const resultLink = document.getElementById("resultLink");
  384. const copyNotification = document.getElementById("copyNotification");
  385. const listDiv = document.querySelector(".list-div");
  386. const cursor = document.querySelector(".cursor");
  387. const searchButton = document.querySelector(".search-button");
  388. // 光标动画函数
  389. function moveCursorTo(element, callback, x = 0, y = 0) {
  390. const rect = element.getBoundingClientRect();
  391. const cursorRect = cursor.getBoundingClientRect();
  392. // 计算光标应该移动到的位置(元素中心)
  393. const targetX = rect.left + rect.width / 2 - cursorRect.width / 2 + x;
  394. const targetY = rect.top + rect.height / 2 - cursorRect.height / 2 + y;
  395. cursor.style.left = targetX + "px";
  396. cursor.style.top = targetY + "px";
  397. setTimeout(callback, 1000); // 等待移动动画完成
  398. }
  399. // 点击光标动画
  400. function clickCursor(callback) {
  401. cursor.classList.add("click");
  402. setTimeout(() => {
  403. cursor.classList.remove("click");
  404. if (callback) callback();
  405. }, 400);
  406. }
  407. // 逐字输入动画
  408. function typeText(text, callback) {
  409. let index = 0;
  410. searchInput.value = "";
  411. function typeNextChar() {
  412. if (index < text.length) {
  413. searchInput.value += text[index];
  414. searchInput.dispatchEvent(new Event("input", { bubbles: true }));
  415. index++;
  416. setTimeout(typeNextChar, 100); // 每个字符间隔 100ms
  417. } else {
  418. if (callback) callback();
  419. }
  420. }
  421. typeNextChar();
  422. }
  423. // 动画序列控制器
  424. function runAnimationSequence(queryValue) {
  425. // 显示光标
  426. cursor.classList.add("visible");
  427. // 步骤 1: 光标从右上角移动到搜索框
  428. setTimeout(() => {
  429. moveCursorTo(
  430. searchInput,
  431. () => {
  432. // 步骤 2: 点击搜索框
  433. clickCursor(() => {
  434. searchInput.classList.add("focused");
  435. // 等待焦点效果,然后开始输入
  436. setTimeout(() => {
  437. // 步骤 3: 逐字输入查询内容
  438. typeText(decodeURIComponent(queryValue), () => {
  439. // 等待输入完成
  440. setTimeout(() => {
  441. // 步骤 4: 光标移动到搜索按钮
  442. moveCursorTo(
  443. searchButton,
  444. () => {
  445. // 步骤 5: 点击搜索按钮
  446. clickCursor(() => {
  447. searchButton.classList.add("clicked");
  448. // 等待点击效果,然后跳转
  449. setTimeout(() => {
  450. // 步骤 6: 跳转到bing搜索
  451. window.location.href = `https://bing.com/search?q=${queryValue}`;
  452. }, 200);
  453. });
  454. },
  455. searchButton.offsetWidth * 0.3,
  456. searchButton.offsetHeight * 0.3
  457. );
  458. }, 100);
  459. });
  460. }, 300);
  461. });
  462. },
  463. searchInput.offsetWidth * 0.4,
  464. searchInput.offsetHeight * 0.3
  465. );
  466. }, 1000); // 1 秒后开始动画
  467. }
  468. // 页面初始化时检查参数 q 的值
  469. function initializePage() {
  470. const urlParams = new URLSearchParams(window.location.search);
  471. let encodedQueryValue = urlParams.get("q");
  472. // 对获取到的编码值进行 Base64 解码
  473. let queryValue = "";
  474. if (encodedQueryValue) {
  475. try {
  476. queryValue = decodeURIComponent(escape(atob(encodedQueryValue)));
  477. } catch (error) {
  478. // 如果解码失败,使用原始值(兼容旧链接)
  479. queryValue = encodedQueryValue;
  480. }
  481. }
  482. // 如果 q 参数无或空,显示 .list-div
  483. if (!queryValue || queryValue.trim() === "") {
  484. listDiv.style.display = "block";
  485. } else {
  486. // 隐藏默认光标
  487. const style = document.createElement("style");
  488. style.textContent = "*,html,:root { cursor: none !important; }";
  489. document.head.appendChild(style);
  490. // 阻止所有鼠标事件和键盘事件
  491. document.addEventListener(
  492. "click",
  493. function (e) {
  494. e.preventDefault();
  495. e.stopPropagation();
  496. e.stopImmediatePropagation();
  497. },
  498. true
  499. );
  500. document.addEventListener(
  501. "mousedown",
  502. function (e) {
  503. e.preventDefault();
  504. e.stopPropagation();
  505. e.stopImmediatePropagation();
  506. },
  507. true
  508. );
  509. document.addEventListener(
  510. "mouseup",
  511. function (e) {
  512. e.preventDefault();
  513. e.stopPropagation();
  514. e.stopImmediatePropagation();
  515. },
  516. true
  517. );
  518. document.addEventListener(
  519. "mousemove",
  520. function (e) {
  521. e.preventDefault();
  522. e.stopPropagation();
  523. e.stopImmediatePropagation();
  524. },
  525. true
  526. );
  527. document.addEventListener(
  528. "keydown",
  529. function (e) {
  530. e.preventDefault();
  531. e.stopPropagation();
  532. e.stopImmediatePropagation();
  533. },
  534. true
  535. );
  536. document.addEventListener(
  537. "keyup",
  538. function (e) {
  539. e.preventDefault();
  540. e.stopPropagation();
  541. e.stopImmediatePropagation();
  542. },
  543. true
  544. );
  545. document.addEventListener(
  546. "keypress",
  547. function (e) {
  548. e.preventDefault();
  549. e.stopPropagation();
  550. e.stopImmediatePropagation();
  551. },
  552. true
  553. );
  554. // 开始动画序列
  555. runAnimationSequence(queryValue);
  556. }
  557. }
  558. initializePage();
  559. // 监听表单提交事件
  560. searchForm.addEventListener("submit", function (event) {
  561. event.preventDefault(); // 阻止表单默认提交行为
  562. const searchValue = searchInput.value.trim();
  563. // 检查输入框是否为空
  564. if (!searchValue) {
  565. alert(isEnglish ? "Please enter search content" : "请输入搜索内容");
  566. return;
  567. }
  568. // 生成搜索链接,对搜索值进行 Base64 编码混淆
  569. const currentUrl = window.location.href.split("?")[0]; // 获取当前页面路径,去除查询参数
  570. const obfuscatedValue = btoa(unescape(encodeURIComponent(searchValue)));
  571. const searchLink = `${currentUrl}?q=${encodeURIComponent(
  572. obfuscatedValue
  573. )}`;
  574. // 在代码块中显示链接
  575. resultLink.textContent = searchLink;
  576. searchResult.style.display = "block";
  577. // 滚动到结果区域
  578. searchResult.scrollIntoView({ behavior: "smooth", block: "nearest" });
  579. });
  580. // 监听结果链接点击事件,实现复制功能
  581. resultLink.addEventListener("click", async function () {
  582. const linkText = resultLink.textContent;
  583. try {
  584. // 使用现代剪贴板 API
  585. await navigator.clipboard.writeText(linkText);
  586. // 显示复制成功提示
  587. copyNotification.classList.add("show");
  588. // 3 秒后隐藏提示
  589. setTimeout(() => {
  590. copyNotification.classList.remove("show");
  591. }, 3000);
  592. } catch (err) {
  593. // 兼容旧版浏览器的备用方案
  594. console.warn("现代剪贴板 API 不可用,使用备用方案");
  595. // 创建临时文本区域
  596. const textArea = document.createElement("textarea");
  597. textArea.value = linkText;
  598. textArea.style.position = "fixed";
  599. textArea.style.left = "-999999px";
  600. textArea.style.top = "-999999px";
  601. document.body.appendChild(textArea);
  602. textArea.focus();
  603. textArea.select();
  604. try {
  605. document.execCommand("copy");
  606. // 显示复制成功提示
  607. copyNotification.classList.add("show");
  608. // 3 秒后隐藏提示
  609. setTimeout(() => {
  610. copyNotification.classList.remove("show");
  611. }, 3000);
  612. } catch (err) {
  613. alert("复制失败,请手动复制链接:" + linkText);
  614. }
  615. // 清理临时元素
  616. document.body.removeChild(textArea);
  617. }
  618. });
  619. // 监听输入框回车键事件,确保在按下回车键时触发表单提交
  620. searchInput.addEventListener("keydown", function (event) {
  621. if (event.key === "Enter") {
  622. event.preventDefault(); // 阻止输入框的默认回车行为
  623. searchForm.dispatchEvent(new Event("submit"));
  624. }
  625. });
  626. // 输入框获得焦点时隐藏之前的结果
  627. searchInput.addEventListener("focus", function () {
  628. searchResult.style.display = "none";
  629. });
  630. </script>
  631. </body>
  632. </html>