类似于这个:https://github.com/jk-oster/obsidian-search-for-web#start-of-content
相关帖子
-
xqh042 •订阅者
-
-
在浏览器插件或油猴脚本中调用下面的代码即可搜索思源的内容(注,以下仅仅是演示 demo,仅供参考)
// 搜索思源内容 function searchBySiYuan(keyword, token, callback = ()=>{}) { const queryParams = { "query": keyword, "method": 0, "types": { "document": true, "heading": true, "list": true, "listItem": true, "codeBlock": true, "htmlBlock": true, "mathBlock": true, "table": true, "blockquote": true, "superBlock": true, "paragraph": true, "embedBlock": true, "databaseBlock": true }, "paths": [], "groupBy": 0, "orderBy": 0, "page": 1 }; // 请求api fetch("http://127.0.0.1:6806/api/search/fullTextSearchBlock", { "headers": { "accept": "*/*", "accept-language": "zh-CN", "cache-control": "no-cache", "content-type": "text/plain;charset=UTF-8", "pragma": "no-cache", "sec-ch-ua": "\"Not-A.Brand\";v=\"99\", \"Chromium\";v=\"124\"", "sec-ch-ua-mobile": "?0", "sec-ch-ua-platform": "\"macOS\"", "sec-fetch-dest": "empty", "sec-fetch-mode": "cors", "Authorization": "Token " + token, "sec-fetch-site": "same-origin" }, "referrerPolicy": "strict-origin-when-cross-origin", "body": JSON.stringify(queryParams), "method": "POST", "mode": "cors", "credentials": "include" }).then(response => response.json()) .then(result => callback(result)) .catch(error => console.log('error', error)); } // 调用 searchBySiYuan('hello', 'your token', (result) => { console.log(result); })
查询结果