diff --git a/贴吧辅助脚本.user.js b/贴吧辅助脚本.user.js new file mode 100644 index 0000000..6b6c66d --- /dev/null +++ b/贴吧辅助脚本.user.js @@ -0,0 +1,70 @@ +// ==UserScript== +// @name 手机贴吧辅助脚本 +// @namespace http://tampermonkey.net/ +// @version 0.1 +// @description try to take over the world! +// @author You +// @match https://tieba.baidu.com/* +// @match https://jump2.bdimg.com/* +// @match https://tiebac.baidu.com/* +// @exclude https://*/index +// @exclude https://*/index* +// @match https://*/f?*kw=* +// @connect https://tieba.baidu.com/mg/o/getFloorData +// @connect https://jump2.bdimg.com/mg/o/getFloorData +// @connect https://tiebac.baidu.com/mg/o/getFloorData +// @icon https://tieba.baidu.com/favicon.ico +// @grant GM_addStyle +// ==/UserScript== + + +(function() { + 'use strict'; + const style = ` + .lzl-post .lzl-post-item { padding-top: 8px; + letter-spacing: 1px; + border-radius: 8px; + margin-bottom: 2px + border: 1px solid rgba(0,0,0,.1); + box-shadow: 5px 5px 5px rgba(0,0,0,0.2);} + .lzl-post .lzl-post-item:nth-child(odd){ background-color:rgba(180, 228, 207, 0.2); } + .lzl-post .lzl-post-item:nth-child(even){ background-color:rgba(168, 191, 157, 0.16); } + `; + GM_addStyle(style); + let check = 0; + if (location.search.indexOf('kw=') > -1 && location.pathname === '/f' && check === 0) { + let ob = new window.MutationObserver(mutations => { + mutations.forEach(item => { + if (item.type === 'childList' && item.addedNodes.length > 0) { + const logo = document.querySelector('.logo-wrapper'); + if (logo) { + const p = logo.parentNode; + const nav = document.createElement('div'); + p.insertBefore(nav, logo) + nav.outerHTML = `
`; + p.removeChild(logo); + check = 1; + document.addEventListener('click',ev => { + if(ev.path[2].classList.contains('logo-wrapper')){ + const e=document.createElement('input'); + const n=ev.path[2] + n.innerHTML=''; + n.append(e) + e.type='text'; + e.addEventListener('blur',ev1 => { + if (e.value) { + location.href = '/f?kw=' + e.value; + } + }) + ev.stopPropagation(); + } + }) + } + } + }) + }); + ob.observe(document.body, { + childList: true + }) + } +})(); \ No newline at end of file