From 5ad656ec70f4957de2099a3ab31c518ee963f8bb Mon Sep 17 00:00:00 2001 From: xing Date: Mon, 27 Jun 2022 04:18:08 +0000 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20'=E6=89=8B=E6=9C=BA?= =?UTF-8?q?=E8=B4=B4=E5=90=A7=E8=BE=85=E5=8A=A9=E8=84=9A=E6=9C=AC.user.js'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 手机贴吧辅助脚本.user.js | 66 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 手机贴吧辅助脚本.user.js diff --git a/手机贴吧辅助脚本.user.js b/手机贴吧辅助脚本.user.js new file mode 100644 index 0000000..2106af5 --- /dev/null +++ b/手机贴吧辅助脚本.user.js @@ -0,0 +1,66 @@ +// ==UserScript== +// @name 手机贴吧辅助脚本 +// @namespace http://tampermonkey.net/ +// @version 0.5 +// @homepage https://code.xloyy.com/xing/tampermonkey-script/ +// @description try to take over the world! +// @author xing +// @match https://tieba.baidu.com/* +// @match https://jump2.bdimg.com/* +// @match https://tiebac.baidu.com/* +// @match https://*/f?*kw=* +// @icon https://tieba.baidu.com/favicon.ico +// @grant GM_addStyle +// @license MIT +// ==/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