显示用户名称,压缩楼层,头像屏蔽,首页布局调整
当前为
// ==UserScript==
// @name 绯月布局调整
// @namespace http://tampermonkey.net/
// @version 1.1.0
// @description 显示用户名称,压缩楼层,头像屏蔽,首页布局调整
// @author aotmd
// @match https://bbs.kfmax.com/*
// @grant none
// ==/UserScript==
let setting={
压缩楼层:true,
头像屏蔽:false,
隐藏背景更改图片:false,
加边框:true,
};
(function () {
addLoadEvent(() => {
window.setTimeout(() => {
let elementNodeListOf = document.querySelectorAll(".indexlbtc > a");
for (let i = 0; i < elementNodeListOf.length; i++) {
let uname=elementNodeListOf[i].getAttribute("uname");
let spanElement = document.createElement('span');
spanElement.className="indexlbtc_u";
elementNodeListOf[i].appendChild(spanElement);
spanElement.appendChild(document.createTextNode(uname));
}
}, 0);
});
addStyle(`
span.indexlbtc_u {
display: inline-block;
float: left;
width: 80px;
/*dtext-align: center;*/
overflow: visible;
white-space: nowrap;
text-overflow: ellipsis;
}
span.indexlbtc_s {
width: 70px!important;
}
span.indexlbtc_t {
width: 450px!important;
}
.indexlbtc {
line-height: normal;
}
`);
addStyle(`
/*布局打回原形*/
.indexlbtc a {
letter-spacing: unset!important;
line-height: unset!important;
height: unset!important;
/*display: unset!important;*/
box-shadow: inset 0px 0px 0px 1px #CCCCCC;
}
.rightboxa {
line-height: normal!important;
border: initial!important;
}
a.k_butt.k_blk {
border: unset!important;
}
`);
if (!setting.加边框){
addStyle(`
.indexlbtc a {
display: unset!important;
}
`);
}
if (setting.压缩楼层){
addStyle(`
/*楼层压缩*/
div[style*="min-height:280px"] {
min-height: auto!important;
}
.readidms {
height: auto;
}
/*缩短头像高度*/
.readidmstop {
height: auto;
line-height: initial;
}
`);
}
if (setting.头像屏蔽){
addStyle(`
/*头像屏蔽*/
/*.readidmstop {
display: none;
}*/
`)
}
if (setting.隐藏背景更改图片){
addStyle(`
/*背景修改图片隐藏*/
a.rightbox2 {
display: none;
}
`);
}
/**
* 添加浏览器执行事件
* @param func 无参匿名函数
*/
function addLoadEvent(func) {
let oldOnload = window.onload;
if (typeof window.onload != 'function') {
window.onload = func;
} else {
window.onload = function () {
try {
oldOnload();
} catch (e) {
console.log(e);
} finally {
func();
}
}
}
}
//添加css样式
function addStyle(rules) {
let styleElement = document.createElement('style');
styleElement["type"] = 'text/css';
document.getElementsByTagName('head')[0].appendChild(styleElement);
styleElement.appendChild(document.createTextNode(rules));
}
})();