Created
December 11, 2021 14:56
-
-
Save sunnylost/d2d81afc713963970647dadef25e7091 to your computer and use it in GitHub Desktop.
豆瓣读书使用 jiumo 搜索快捷脚本
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name 豆瓣jiumo图书搜索 | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description 将书籍标题替换为 jiumo 搜索链接 | |
// @author You | |
// @match https://book.douban.com/subject/* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
let el = document.querySelector('#wrapper > h1 span') | |
let link = document.createElement('a') | |
let content = link.innerHTML = el.innerHTML | |
link.target = '_blank' | |
link.href = 'https://www.jiumodiary.com/?search=' + content | |
el.replaceWith(link) | |
})(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name jiumo search | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description 解析从豆瓣跳转携带的参数,自动执行搜索 | |
// @author You | |
// @match https://www.jiumodiary.com/* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
location.search.substring(1).split('&').some(v => { | |
let [key, val] = v.split('=') | |
if(key === 'search') { | |
runSearch(val) | |
return true | |
} | |
}) | |
function runSearch(keyword) { | |
if(typeof window.validate !== 'function') { | |
setTimeout(() => { | |
runSearch(keyword) | |
}, 1000) | |
} else { | |
window.validate(keyword) | |
document.getElementById('SearchWord').value = decodeURIComponent(keyword) | |
} | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment