Greasy Fork is available in English.
替代贴吧APP,需要配合user-agent switcher 切换成PC模式
当前为
// ==UserScript==
// @name 贴吧手机版
// @namespace https://space.bilibili.com/8286319
// @version 1.1
// @description 替代贴吧APP,需要配合user-agent switcher 切换成PC模式
// @author happmaoo
// @match https://tieba.baidu.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=baidu.com
// @grant GM_addStyle
// ==/UserScript==
function viewport() {
if (document.querySelector('meta[name="viewport"]')) {
return;
}
const el = document.createElement("meta");
el.name = "viewport";
el.content = "width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no";
document.head.append(el);
}
(function() {
'use strict';
// Your code here...
viewport();
var mycss2 = `
.j-placeholder-pay-member,.p_share_ding,#d_post_manage,.j_clear_fullscreen,.dialogJmodal,.tbshare_popup_wrapper,.ui_bubble_wrap,.footer,.homeworks_guide,.tbui_aside_smiley,.ip-location,.p_mtail,.lzl_more,.replace_tip,.poster_head,.d_badge_title,.d_badge_lv,.threadlist_detail>.threadlist_author,.head_content,.share_btn_wrapper,.icon-jubao,.user-hide-post-down,.right_section,.suggestion_list,.search_top,#fixed_bar,.aside,.nav_wrap,.userbar,.card_banner,.card_top_wrap{display:none!important;}
ul,li{list-style-type:none;padding:0px;margin:0;}
.aaaa{padding:0px!important;margin:0!important;width:auto!important;margin:0!important;}
.search_ipt{width:100px!important;}
.search_logo::before {
content: "贴吧";
color: #4CAF50;
float: left;
display: block;
width: 40px;
height: 20px;
}
.search_btn{margin-right:10px;}
/* 列表 */
#thread_list{padding:0px;}
.threadlist_author{float:right;font-size:14px;color:#777!important;}
.threadlist_author a{font-size:14px;color:#777!important;}
.threadlist_media li,.col2_left{float:left;}
.threadlist_rep_num{background:#ffe1a9;padding:0 5px;margin-right:5px;font-size:14px;}
.j_thread_list{background:#fff;overflow:hidden;margin:0 0 10px 0;}
.j_thread_list a{text-decoration:none;color:#222;}
.threadlist_text{font-size:14px;color:#999; height: 50px; overflow: hidden;}
/* 回复相关 */
.d_post_content_main{display:block;}
.d_post_content img{max-width:300px;height:auto;}
.core_reply_content{background:#eee;margin-left:20px;padding:5px 10px;font-size:14px!important;}
.core_reply_content .j_user_card img{display:none;}
.p_author img{width:50px;height:auto;}
.lzl_jb{width:0;height:0;}
.core_reply_tail ul,.p_reply{float:left;font-size:12px;color:#aaa;}
.core_reply_tail .p_tail li{float:left;}
.core_reply_content a,.core_reply_tail a{color:#888;}
.d_name a{color:#888;text-decoration:none;font-size:14px;}
.p_author{float:left;}
.l_post{background:#fff;overflow:hidden;border-bottom: 1px solid #aaa;margin: 10px 0;padding-bottom:10px;}
.post-tail-wrap,.post-tail-wrap a{font-size:12px;color:#aaa;}
/* 编辑器相关 */
.edui-popup{display:block;background:#eee;border: 1px solid #aaa;padding:20px;}
.edui-btn-image{}
.edui-btn-image::before {
content: "图";
color:#fff;
text-align: center;
display:block;width:30px;height:30px;background:#4CAF50;
font-size: 14px; /* 设置字体大小 */
}
.next_step{display:block;width:100px;height:20px;background:#aaa;}
.slide_item{float:left;display:none;}
.j_ok {
position: fixed; /* 设置为固定定位 */
left: 0; /* 距离左边 0 像素 */
bottom: 0; /* 距离底部 0 像素 */
background-color: rgba(0, 0, 0, 0.7); /* 背景颜色 */
color: white; /* 字体颜色 */
padding: 10px; /* 内边距 */
}
.i_item_bg{width:60px;height:60px;}
.flash_editor_container,.error{display:none;}
.edui-container .BDE_Image{width:100px!important;height:auto!important;}
#ueditor_replace{width:350px!important;}
.edui-container{width:350px!important;}
.dialogJbody{height:250px!important;}
.poster_submit{margin:5px;display:block;padding:5px;width:100px;background:#eee;text-align: center;font-size: 16px;text-decoration:none;}
.poster_submit em{color:#000;font-style: normal!important;}
.edui-editor-body{border: 1px solid #aaa;}
/* reply 回复楼中楼 */
.core_reply_content ul {
max-height:200px; /* 鼠标悬停时显示内容 */
overflow: auto;
}
.core_reply_content----:hover ul {
height:auto; /* 鼠标悬停时显示内容 */
}
.core_reply_tail{clear:both; display: block; overflow: hidden;}
.post-tail-wrap span{float:left;}
video{display:none;}
.l_post{
display: flex;
flex-direction: row;
}
.BDE_Image{width:auto!important;}
.l_post .d_author{display:block;width:60px;font-size:14px;}
.test{background:#0f0;}
/* 翻页 */
.pagination-default span,.pagination-default a{float:left;margin-left:5px;display:block;padding:2px 5px;background:#eee;}
.pagination-default{clear:both;overflow: hidden;}
`;
$('link[rel="stylesheet"], style').remove();
GM_addStyle(mycss2);
// 每 1 秒执行一次
setInterval(function() {
// 插入图片相关
$('html').css({
'overflow': '', // 清除 overflow 样式
'padding-right': '' // 清除 padding-right 样式
});
$('.dialogJfix').css({
'position': 'fixed',
'padding': '20px', // 清除 overflow 样式
'left': '50px',
'width': '300px',
'border': '1px solid #aaa',
'background': '#eee' // 清除 padding-right 样式
});
// 查找内容为 "广告" 的 span
$('span').filter(function() {
return $(this).text().trim() === '广告';
}).each(function() {
$(this).parent().html('ad1');
});
$('.l_post[data-field="{}"]').remove();
$('video').remove();
$('#thread_list>div').remove();
$('.p_postlist').children().not('.l_post, .p_postlist').html('ad2');
}, 1000);
// 贴吧主页
if (window.location.href === 'https://tieba.baidu.com/' || window.location.href === 'https://tieba.baidu.com/index.html') {
var mycssindex = `
html{padding:20px;}
a{margin-right:10px;}
`;
GM_addStyle(mycssindex);
$('img').remove();
// 获取 ID 为 likeforumwraper 的元素的 HTML 内容
var newContent = $('.left-sec').html();
// 替换整个 body 的内容
$('body').html(newContent);
} else {
}
})();