Skip to content

Latest commit

 

History

History
390 lines (339 loc) · 16.8 KB

系统项.md

File metadata and controls

390 lines (339 loc) · 16.8 KB

[系统项]使用说明(了解新功能)

1、基本使用:ctrl+alt+s呼出 Esc 隐藏 2、内容类型说明:有链接内容(点击后跳转),与简述内容,点击后直接可查看的简述文本 3、制作订阅,请查看内置订阅,按着来。 4、“搜索PRO”模式,搜索语法: "<搜索出可搜索,如baidu><tab键><baidu搜索的内容,如 今日热点>"
取消搜索PRO模式:shift+tab 5、新添加/修改的内容,都会有“NEW”的标签,快搜索“NEW”试试吧~ (查看最近7天) 6、呼出搜索框直接按tab键,输入问题再回车即可体现AI简单问答功能。

官方Github Wiki | 更新日志

[系统项] 关于脚本(作者 & 脚本)

作者: Zhuang Jie 联系信息: [email protected] 脚本简述: 我一直热爱收集各类软件和网站,因此积累了大量的信息。之前,我常常通过文字搜索(使用 Ctrl+F 方式)在记录中找到所需信息。然而,这种方式并不总是高效而直观。因此,我开发了这款脚本,它可以帮助我更快地检索和导航到我需要的信息。通过这款脚本,我能够更有效地管理并使用我的收集的所有资源。 更新日志 | 意见反馈/内容提交 | 官方微信公众-订阅号(“我的搜索-搜我想搜”)

基本素养:

  1. 国际网络教程 | 我的搜索福利机场:>>一键导入<<

脚本技术支持:

作者作品:

支持作者 如果你觉得我们的产品有价值,并希望我们能持续改进和开发新的功能,我们真诚的请求你考虑支持我们。你可以选择捐款。每一次的支持,对我们都非常重要。

微信/支付宝

[h'脚本'][系统项]新数据项(订阅作者新添加的项)

-- env -- _icon data:image/svg+xml;base64,PHN2ZyB2ZXJzaW9uPSIxLjIiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgdmlld0JveD0iMCAwIDY0IDY0IiB3aWR0aD0iNjQiIGhlaWdodD0iNjQiPgoJPHRpdGxlPuaWsOW7uumhueebrjwvdGl0bGU+Cgk8c3R5bGU+CgkJLnMwIHsgZmlsbDogI2ZmMDAwMCB9IAoJCS5zMSB7IG9wYWNpdHk6IC42O2ZpbGw6ICNmZjAwMDAgfSAKCQkuczIgeyBvcGFjaXR5OiAuNDtmaWxsOiAjZmYwMDAwIH0gCgk8L3N0eWxlPgoJPHBhdGggaWQ9IuW9oueKtiAxIiBjbGFzcz0iczAiIGQ9Im00LjggMTQuMWg1NC4ydjYuOGgtNTQuMnoiLz4KCTxwYXRoIGlkPSLlvaLnirYgMyIgY2xhc3M9InMxIiBkPSJtNSAyOC4xaDU0djYuOGgtNTR6Ii8+Cgk8cGF0aCBpZD0i5b2i54q2IDQiIGNsYXNzPSJzMiIgZD0ibTUgNDIuMWg1NHY2LjhoLTU0eiIvPgoJPHBhdGggaWQ9IuW9oueKtiAyIiBjbGFzcz0iczAiIGQ9Im0zMiAzMnoiLz4KPC9zdmc+ -- script -- function ( {registry} ) { registry.searchData.triggerSearchHandle(registry.searchData.specialKeyword.new); }

[h'脚本']历史记录(最近查看的项)

-- env --

-- script -- function ( {registry} ) { registry.searchData.triggerSearchHandle(registry.searchData.specialKeyword.history); }

[h'脚本'] 我的HOT(脚本使用者经常选择的项)

-- env --

-- script -- function ( {registry} ) { registry.searchData.triggerSearchHandle(registry.searchData.specialKeyword.highFrequency); }

[h'脚本'][h'问AI'][h'系统项'] AI(使用ChatGPT作为服务端,集成到本脚本,实现快捷的AI问答功能)

-- env -- _icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAGhklEQVRYhbWXXWwU1xXHf+fO7OynbWxsmuAAKimEEqUSMuCS9AOJNiQEaiJEgps2TmmShzwkipSHqm0atRUPUQUFSl7SVggsHqJSMAioUNsQq2qRwKGqqJRCIRAjGxUw/lh/7OzMvacPa1PM2gYa8pdWu3fvOef333Nn7t4R7kJPt0RNwEpgMTAXqB6d6gXOAx3A0f27EgfvtKbcFvp8VIOyHeG520br/94VWvHltbadfu//bWDd2nCL+vK6eoAHeFLKuDlLAQfqFOzoeMyIAWBz23vBG3dl4NsrhiscetYac5/zQH1BA4GEgC8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VY/lNYVnc8krXvPt4rttqw4Uk/1/NS4pJ6eHjo7O1m0aNGk8Ft15coVLl68yNKlS2989+9Lw6x79wJVc3zCGg+X8dYLQOs3L6nnFCJHdrbPt1rrJy38afSdHRf42DjcdEOxWvn7ygfFAES+ORgmDMW0z9VzjpO7+u45/Lfv9/CPWHDTfIoVECdtG4yeB5zwqjOC9QSp8Tjxq0FO/2HwnsEPdgzy01MjpGo9CpWOMBsTZu2rNwy8eKT+E4U9Ywfa4HMef3prgPd/PfCp4TuODvDKBwPUzVCKFTFhxhIFrvXski9egluOZL9Z1VUAkg4hwjA4BEF9gqffrGDOgvJteir985OIH7T187GNyNRYolxMVGmJMnHh3FcXpMfi/JuTBBY45IJDcIBXYcj3Ktu+n6d6QYLlzyZ5uCFBzfSJd8OrfY4TZ4rs+tswp/ojqquVbJUjTjls2uESDvV56BbmeL27qnuxRU4WRSiIR0EMBQzDzjAYGvojQzEHDyw05GYoLlCujsScvhozjJJKK8msQzIlaJwZ+/+PsSldfPbr8z+c0gDAO6suzwvFnCmIJwUxFMQQYgjFEBrDiBGGEjCScURZi6YtpByacNjA4ZIOl3LEaYvNOOKMdXHSPnTmG/PP3cqa8tHs56uvHSmI92RBDKEIoXgUEUJjKARQTCtR1hJnY2wmxiYtNuVwScWmLHHa4lLuyOm1c5+ajDHxxj6qNw/VrnLIYgcdpetCcCI4FbAGKQpSNJjIINaglB7FnO9wCXdSfW2YCn7bDtysl9cO1UYiz4eYxyNjlkYi1TahxIErtTkX90aVxRNxRXQ0zrrdJ1+q77mTuv8FAufMP1b9MjIAAAAASUVORK5CYII=

_describe 使用的公益chatGPTApi来支持的内置AI助手 -- script -- function main({ cache, $, view }) { view.mount(); }

-- view:html --

知识库/提示词(即将推出..): 📕联网知识库 📄读当前页面 🗂️基于搜索项
send

-- view:css --

#chat-control { display: flex; align-items: stretch; height: 30px; } #chat-control select, #chat-control input, #chat-control button { padding: 5px 10px; margin-right: 2px; font-size: 14px; }

#conversation-history { margin-bottom: 1rem; border: 1px solid #ccc; padding: 0.5rem; min-height: 50px; } pre { display: flex; flex-direction: column; margin: 3px 0; } pre .code-type { display: block; margin: 2px 5px; color: #bcbcbc; /代码类型不可选中/ -webkit-touch-callout: none; -webkit-user-select: none; -khtml-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none;

}

.你-message { color: #007BFF; }

.AI-message { color: #28A745; }

#loading { display: inline-block; width: 20px; height: 20px; border: 4px solid rgba(0, 0, 0, 0.1); border-top-color: #000; border-radius: 50%; animation: spin 1s linear infinite; } #prompt { margin: 10px 0; height: 28px; display: flex; } #prompt > .optional { background: #ededed; border-radius: 8px; color: #7a7a7a; padding: 0 6px; cursor: pointer; margin-right: 4px; } #prompt input { border-radius: 8px; font-size: 10px; padding: 0px 10px; border: 1px solid #6e6e6e; } @keyframes spin { to { transform: rotate(360deg); } }

-- view:js -- console.log("进入viewScript") const headers = new Headers(); headers.append("Content-Type", "application/json"); function getAnyOne(keys = []) { const randomIndex = Math.floor(Math.random() * keys.length); return keys[randomIndex]; } function trimString(str, trimStr) { // 使用正则表达式去除前后指定的字符串 const regex = new RegExp(^${trimStr}|${trimStr}$, 'g'); return str.replace(regex, ''); } // 编码:window.btoa("raw") // 解码:window.atob("processed") const providerList = [ 'ewogICAgImJhc2VVcmwiOiBbImh0dHBzOi8vZnJlZS52MzYuY20vdjEiXSwKICAgICJrZXlzIjogWwogICAgICAic2stNElJcFRPdDgwTmR0STZHOTEyRGExZkY4N2YzYTRhMGJCYjA2MmVBNDQ3N2NDMjUyIiwKICAgICAgInNrLWxSdFo5dTdyYTcwcjJZQjhCODBlOWNEMDE4MDA0MUI1QWM0MjcwQzBBMzgwMWUwMCIsCiAgICAgICJzay12cnI1WWVQMWlmYkp2S3VVMzNDOERkQjMwM0I5NDczM0E3Q2RDYzE0RTJEY0U4QWYiCiAgICBdLAogICAgIm1vZGVsIjogWyJncHQtNG8tbWluaSIsImdwdC0zLjUtdHVyYm8tMDEyNSIsImdwdC0zLjUtdHVyYm8tMTEwNiIsInNlbGVjdGVkOmdwdC0zLjUtdHVyYm8iLCJncHQtMy41LXR1cmJvLTE2ayIsIm5ldC1ncHQtMy41LXR1cmJvIiwid2hpc3Blci0xIiwiZGFsbC1lLTIiXQogIH0=',

'ewogICAgImJhc2VVcmwiOiBbImh0dHBzOi8vYXBpLmNoYXRhbnl3aGVyZS50ZWNoL3YxIiwiaHR0cHM6Ly9hcGkuY2hhdGFueXdoZXJlLm9yZy92MSJdLAogICAgImtleXMiOiBbCiAgICAgICJzay1hYVU4dkM3Sk93dXpQRUpVaXJENXVqb3cyWndTTUNIc3lGT2pTbUM1Z2EwY0hWNTQiLAogICAgICAic2stM2p6Y0FhUGg2NGVvUENzQWREMmI3V0RESVZPcW0yQ2FUc0dLQVdFTFVaYXJNSXRpIiwKICAgICAgInNrLUpjdDltUVJXMEpqdzZ2OG9qSU9Qb3J1MklkbEd3ZlVoRmFwZW4xSnQxemZUazN5SyIKICAgIF0sCiAgICAibW9kZWwiOiBbImdwdC00Iiwic2VsZWN0ZWQ6Z3B0LTMuNS10dXJibyIsImdwdC00LWNhIiwiZ3B0LTMuNS10dXJiby1jYSJdCiAgfQ==' ] // 选择一个服务提供者信息 let sessionProvider = { ...(typeof providerList[0] === "string" ? JSON.parse(atob(getAnyOne(providerList))) : getAnyOne(providerList)), chooseOut: function() { return { baseUrl: getAnyOne(sessionProvider.baseUrl), key: getAnyOne(sessionProvider.keys), defaultChooseModel: trimString(this.model.find(m => m.startsWith("selected:")) || this.model[0],"selected:") } } } let sessionProviderSpecific = sessionProvider.chooseOut();

// 历史对话记录 let conversationHistory = [{ role: "system", content: "你是乐于助人AI助理" }]; let isLoading = false; const inputDocument = document.getElementById("input"); const sendBtn = document.querySelector("#chat-btn"); const selectElement = document.getElementById("model-select"); headers.append("Authorization", Bearer ${sessionProviderSpecific.key}); // 将模型放到下拉框中 sessionProvider.model.forEach(currentModel => { const option = document.createElement("option");

option.selected = (currentModel = trimString(currentModel,"selected:")) === sessionProviderSpecific.defaultChooseModel; option.value = option.textContent = currentModel;

selectElement.appendChild(option); });

function chatClickAction() { openLoading(); inputDocument.value = '' // disable 按钮 sendBtn.disabled = true; }

function chat() { if(sendBtn.disabled) return;

const userInput = inputDocument.value; const messageId = "user-" + Date.now();

conversationHistory.push({ role: "user", content: userInput }); appendToConversationHistory("你", userInput, messageId); chatClickAction();

const requestOptions = { method: 'POST', headers, body: JSON.stringify({ model: selectElement.value, // 下拉框ai框架选择值 messages: conversationHistory, stream: true }), };

fetch(${sessionProviderSpecific.baseUrl}/chat/completions, requestOptions) .then(async response => { const reader = response.body.getReader(); const decoder = new TextDecoder(); let partialMessage = ""; // Partial message from the stream let aiMessage = '' // 消息id,用于标识消息div const messageId = "assistant-" + Date.now();

  while (true) {
    const { done, value } = await reader.read();
    if (done) {
      console.log("Stream complete");
      conversationHistory.push({ role: "assistant", content: aiMessage });
      document.querySelector("#chat-btn").disabled = false;
      return;
    }
    if (isLoading) closeLoading();

    const chunk = decoder.decode(value, { stream: true });
    let messages = (partialMessage + chunk).split("\n");
    partialMessage = messages.pop();

    // 过滤数组里的空字符串
    messages = messages.filter(message => message);

    for (const message of messages) {
      if (!message) continue; // 忽略空字符串
      if (message === "data: [DONE]") {
        break;
      }
      const jsonStartIndex = message.indexOf("{");
      const jsonData = message.slice(jsonStartIndex);
      const dataObject = JSON.parse(jsonData);

      const aiResponse = dataObject.choices[0].delta.content;
      if (aiResponse) {
        aiMessage += aiResponse;
        console.log(aiResponse);
        appendToConversationHistory("AI", aiMessage, messageId);
      }

    }
  }
})
.catch(error => console.log('error', error));

}

function appendToConversationHistory(role, content, messageElementId) { const historyContainer = document.getElementById("conversation-history");

let messageElement = document.getElementById(messageElementId); if (!messageElement) { messageElement = document.createElement("div"); messageElement.id = messageElementId; messageElement.classList.add(role + "-message"); historyContainer.appendChild(messageElement); }

let formattedContent = nextLineMedials(true,content);

// 检查内容中是否包含代码块标记 const codeBlockRegex = /(\w+)?([\s\S]*?)|([^]+)/g; formattedContent = formattedContent.replace(codeBlockRegex, (match, lang, blockContent, inlineContent) => { if (blockContent) { blockContent = trimString( nextLineMedials(false,blockContent,"\n"), "\n") return

${lang || "plaintext"}
${escapeHtml(blockContent)}
; } else if (inlineContent) { inlineContent = nextLineMedials(false,inlineContent,"\n") // 处理行内代码,将HTML标签字符转义 return ${escapeHtml(inlineContent)} `; } return match; }); formattedContent = nextLineMedials(false,formattedContent,"
")

messageElement.innerHTML = role + " : " + formattedContent; }

// \n => 中间字符 =>
| \n function nextLineMedials(isToMedials = true, content = "", target = "") { if(isToMedials) { return content.replace(/(\n)+/g, "[[$换行$]]") } else { return content.replace(/[[$换行$]]/g, target); } } // 去除两边的\n function trimNewlines(str) { return str.replace(/^\n+|\n+$/g, ''); } // 转义 HTML 标签字符(代码块特殊字符也直接显示,相当innerText) function escapeHtml(str) { return str.replace(/[&<>"'/]/g, function (match) { const escapeMap = { '&': '&', '<': '<', '>': '>', '"': '"', "'": ''', '/': '/' }; return escapeMap[match]; }); }

function openLoading() { isLoading = true; // 创建loading 节点 const loadingElement = document.createElement("div"); loadingElement.id = "loading"; loadingElement.style.display = "inline-block"; // 挂在到historyContainer document.getElementById("conversation-history").appendChild(loadingElement); }

function closeLoading() { isLoading = false; // 删除loading节点 document.getElementById("loading").remove(); }

// 给发送按钮绑定点击事件 sendBtn.addEventListener("click", () => chat()); // 监听msg push 事件(新版本使用MS_SCRIPT_ENV替换原来的MS_script_env_var,下面写有兼容代码) (window.MS_SCRIPT_ENV || window.MS_script_env_var).event.sendListener.push((fillKeyword)=> { console.log("已接收到:", fillKeyword); if (${fillKeyword}.trim().length === 0) return; inputDocument.value = fillKeyword; // 手动设置值 chat(); // 点击send }); // 回车发送事件 inputDocument.addEventListener('keypress', function(event) { // 检查是否按下了 "Enter" 键 if (event.key === 'Enter') { // 阻止默认行为(防止在表单中触发提交等) event.preventDefault(); // 触发按钮点击 chat(); } });