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

69 lines
2.9 KiB
JavaScript
Raw Normal View History

2022-06-27 03:47:45 +00:00
// ==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() {
2022-06-27 03:43:57 +00:00
'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
})
2022-06-27 03:47:45 +00:00
}
})();