tampermonkey-script/手机贴吧辅助脚本.user.js

66 lines
2.7 KiB
JavaScript
Raw Permalink Normal View History

// ==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 = `<div data-v-4e54bd24="" class="logo-wrapper"><svg data-v-4e54bd24="" class="nav-bar-icon-top"><use xlink:href="#icon_logo_top"></use></svg></div>`;
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
})
}
})();