|
|
@@ -268,6 +268,25 @@
|
|
|
filter: drop-shadow(0 0 0.3rem black);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ /* 自定义搜索引擎输入框样式 */
|
|
|
+ .search-engine-input {
|
|
|
+ box-sizing: border-box;
|
|
|
+ padding: 12px;
|
|
|
+ font-size: 16px;
|
|
|
+ border: none;
|
|
|
+ background: #f5f5f5;
|
|
|
+ width: 100%;
|
|
|
+ }
|
|
|
+
|
|
|
+ /* 深色模式下的自定义搜索引擎输入框样式 */
|
|
|
+ @media (prefers-color-scheme: dark) {
|
|
|
+ .search-engine-input {
|
|
|
+ background: #333333;
|
|
|
+ color: #f1f1f1;
|
|
|
+ border: 1px solid #555555;
|
|
|
+ }
|
|
|
+ }
|
|
|
</style>
|
|
|
</head>
|
|
|
<body>
|
|
|
@@ -302,7 +321,7 @@
|
|
|
</button>
|
|
|
</form>
|
|
|
|
|
|
- <!-- 搜索结果显示区域 -->
|
|
|
+ <!-- 搜索链接区域 -->
|
|
|
<div class="search-result" id="searchResult" style="display: none">
|
|
|
<div class="result-code-block" id="resultLink" title="点击复制链接">
|
|
|
<!-- 搜索链接将在这里显示 -->
|
|
|
@@ -327,10 +346,18 @@
|
|
|
<p>将生成的链接复制到剪贴板,发给不愿意或不会自己搜索的人类。</p>
|
|
|
</li>
|
|
|
</ol>
|
|
|
+ <!-- 自定义搜索引擎输入框 -->
|
|
|
+ <input
|
|
|
+ type="text"
|
|
|
+ class="search-engine-input"
|
|
|
+ id="searchEngineInput"
|
|
|
+ placeholder="https://bing.com/search?q=QUERY"
|
|
|
+ />
|
|
|
<a
|
|
|
onclick="javascript:window.open('?q=Z2l0IHJlcG8gc2VhcmNoLWl0LXlvdXJzZWxmIHBqNTY4')"
|
|
|
- >项目源码</a
|
|
|
>
|
|
|
+ 项目源码
|
|
|
+ </a>
|
|
|
</div>
|
|
|
|
|
|
<div class="cursor">
|
|
|
@@ -421,11 +448,7 @@
|
|
|
|
|
|
return isEnglish;
|
|
|
}
|
|
|
-
|
|
|
- // 初始化时执行语言检测
|
|
|
- document.addEventListener("DOMContentLoaded", function () {
|
|
|
- detectLanguage();
|
|
|
- });
|
|
|
+ detectLanguage();
|
|
|
|
|
|
// 获取页面元素
|
|
|
const searchForm = document.getElementById("searchForm");
|
|
|
@@ -437,6 +460,8 @@
|
|
|
const cursor = document.querySelector(".cursor");
|
|
|
const searchButton = document.querySelector(".search-button");
|
|
|
|
|
|
+ const defaultSearchEngine = "https://bing.com/search?q=QUERY";
|
|
|
+
|
|
|
// 光标动画函数
|
|
|
function moveCursorTo(element, callback, x = 0, y = 0) {
|
|
|
const rect = element.getBoundingClientRect();
|
|
|
@@ -481,7 +506,7 @@
|
|
|
}
|
|
|
|
|
|
// 动画序列控制器
|
|
|
- function runAnimationSequence(queryValue) {
|
|
|
+ function runAnimationSequence(queryValue, searchEngineUrl) {
|
|
|
// 显示光标
|
|
|
cursor.classList.add("visible");
|
|
|
|
|
|
@@ -511,8 +536,13 @@
|
|
|
|
|
|
// 等待点击效果,然后跳转
|
|
|
setTimeout(() => {
|
|
|
- // 步骤 6: 跳转到bing搜索
|
|
|
- window.location.href = `https://bing.com/search?q=${encodeURIComponent(queryValue)}`;
|
|
|
+ // 步骤 6: 跳转到自定义搜索引擎
|
|
|
+ // 将 QUERY 替换为实际的搜索内容
|
|
|
+ const searchUrl = searchEngineUrl.replace(
|
|
|
+ "QUERY",
|
|
|
+ encodeURIComponent(queryValue)
|
|
|
+ );
|
|
|
+ window.location.href = searchUrl;
|
|
|
}, 200);
|
|
|
});
|
|
|
},
|
|
|
@@ -534,6 +564,7 @@
|
|
|
function initializePage() {
|
|
|
const urlParams = new URLSearchParams(window.location.search);
|
|
|
let encodedQueryValue = urlParams.get("q");
|
|
|
+ let encodedSearchEngineValue = urlParams.get("se");
|
|
|
|
|
|
// 对获取到的编码值进行 Base64 解码
|
|
|
let queryValue = "";
|
|
|
@@ -546,6 +577,32 @@
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ // 对获取到的自定义搜索引擎值进行 Base64 解码
|
|
|
+ let searchEngineValue = ""; // 格式形似:https://example.com/search?q=QUERY
|
|
|
+ if (encodedSearchEngineValue) {
|
|
|
+ try {
|
|
|
+ searchEngineValue = decodeURIComponent(
|
|
|
+ escape(atob(encodedSearchEngineValue))
|
|
|
+ );
|
|
|
+ } catch (error) {
|
|
|
+ // 如果解码失败,使用默认值
|
|
|
+ searchEngineValue = defaultSearchEngine;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 如果没有提供自定义搜索引擎,或自定义搜索引擎没有“QUERY”,使用默认的 Bing 搜索
|
|
|
+ if (
|
|
|
+ !searchEngineValue ||
|
|
|
+ searchEngineValue.trim() === "" ||
|
|
|
+ !searchEngineValue.includes("QUERY")
|
|
|
+ ) {
|
|
|
+ searchEngineValue = defaultSearchEngine;
|
|
|
+ } else {
|
|
|
+ // 设置自定义搜索引擎输入框的占位符值为
|
|
|
+ document.getElementById("searchEngineInput").placeholder =
|
|
|
+ searchEngineValue;
|
|
|
+ }
|
|
|
+
|
|
|
// 如果 q 参数无或空,显示 .list-div
|
|
|
if (!queryValue || queryValue.trim() === "") {
|
|
|
listDiv.style.display = "block";
|
|
|
@@ -627,7 +684,7 @@
|
|
|
);
|
|
|
|
|
|
// 开始动画序列
|
|
|
- runAnimationSequence(queryValue);
|
|
|
+ runAnimationSequence(queryValue, searchEngineValue);
|
|
|
}
|
|
|
}
|
|
|
initializePage();
|
|
|
@@ -647,9 +704,49 @@
|
|
|
// 生成搜索链接,对搜索值进行 Base64 编码混淆
|
|
|
const currentUrl = window.location.href.split("?")[0]; // 获取当前页面路径,去除查询参数
|
|
|
const obfuscatedValue = btoa(unescape(encodeURIComponent(searchValue)));
|
|
|
- const searchLink = `${currentUrl}?q=${encodeURIComponent(
|
|
|
+
|
|
|
+ // 获取当前页面输入框中自定义搜索引擎值(优先级高于当前 URL 中的 se 参数)
|
|
|
+ const currentSearchEngine = document
|
|
|
+ .getElementById("searchEngineInput")
|
|
|
+ .value.trim();
|
|
|
+
|
|
|
+ // 获取当前 URL 中的 se 参数(如果有)
|
|
|
+ const urlParams = new URLSearchParams(window.location.search);
|
|
|
+ const paramSearchEngine = urlParams.get("se");
|
|
|
+
|
|
|
+ // 验证自定义搜索引擎格式,确保包含 QUERY 占位符
|
|
|
+ let validSearchEngine = "";
|
|
|
+ if (currentSearchEngine && currentSearchEngine.includes("QUERY")) {
|
|
|
+ validSearchEngine = currentSearchEngine;
|
|
|
+ }
|
|
|
+ // 检查 URL 参数中的搜索引擎(需要先解码再验证)
|
|
|
+ else if (paramSearchEngine) {
|
|
|
+ let decodedSearchEngine = "";
|
|
|
+ try {
|
|
|
+ // 尝试 Base64 解码
|
|
|
+ decodedSearchEngine = decodeURIComponent(
|
|
|
+ escape(atob(paramSearchEngine))
|
|
|
+ );
|
|
|
+ } catch (error) {
|
|
|
+ // 如果解码失败,使用默认值
|
|
|
+ decodedSearchEngine = defaultSearchEngine;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 验证解码后的搜索引擎是否包含 QUERY
|
|
|
+ if (decodedSearchEngine.includes("QUERY")) {
|
|
|
+ validSearchEngine = decodedSearchEngine;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 构建搜索链接,包含原有的搜索引擎参数
|
|
|
+ let searchLink = `${currentUrl}?q=${encodeURIComponent(
|
|
|
obfuscatedValue
|
|
|
)}`;
|
|
|
+ if (validSearchEngine) {
|
|
|
+ searchLink += `&se=${btoa(
|
|
|
+ unescape(encodeURIComponent(validSearchEngine))
|
|
|
+ )}`;
|
|
|
+ }
|
|
|
|
|
|
// 在代码块中显示链接
|
|
|
resultLink.textContent = searchLink;
|