]*>/gi, '')
.replace(/<\/div>/gi, '
')
.replace(/
]*>/gi, '')
.replace(/<\/p>/gi, '
')
.replace(/
\s*
/gi, '
')
.trim();
}
}
// 提取修改理由/锁定理由
let reasonText = '';
// 遍历所有子节点,查找包含"修改理由"或"锁定理由"的文本
$item.contents().each(function() {
if (this.nodeType === 3) { // 文本节点
const text = $(this).text().trim();
// 检查是否包含"修改理由"或"锁定理由"
if (text.includes('修改理由') || text.includes('锁定理由')) {
// 尝试提取冒号后的内容
const colonIndex = text.indexOf(':');
if (colonIndex !== -1) {
reasonText = text.substring(colonIndex + 1).trim();
} else {
// 尝试英文冒号
const colonIndex2 = text.indexOf(':');
if (colonIndex2 !== -1) {
reasonText = text.substring(colonIndex2 + 1).trim();
}
}
}
}
});
// 如果通过文本节点没找到,尝试直接查找包含理由的文本
if (!reasonText) {
const itemText = $item.text();
const reasonMatch = itemText.match(/(?:修改理由|锁定理由)[::]\s*(.+?)(?:\n|$)/);
if (reasonMatch) {
reasonText = reasonMatch[1].trim();
}
}
// 创建时间轴条目HTML
let contentSections = '';
if (actionType.includes('添加了问题')) {
// 对于添加问题,分开显示标题和补充说明
contentSections = `
${changeContent}
${supplementContent ? `
${supplementContent}` : ''}
`;
} else if (isLockAction || isUnlockAction) {
// 锁定或解锁操作
let lockIcon = '';
let lockClass = '';
// 根据操作类型设置不同的样式
if (isUnlockAction) {
// 解锁操作 - 绿色
lockIcon = `
`;
lockClass = ' unlock-success';
} else {
// 锁定操作 - 红色
lockIcon = `
`;
lockClass = ' lock-warning';
}
contentSections = `
${lockIcon}
${changeContent || actionType}
`;
}else if (isCloseAction) {
// 关闭操作 - 灰色叉号图标,使用.close-warning类
const closeIcon = `
`;
contentSections = `
${closeIcon}
${changeContent || actionType}
`;
}else if (changeContent) {
// 其他有修改内容的操作
contentSections = `
`;
}
// 判断是否为特殊用户,决定是否显示"用户:"前缀
const userText = userElement.text().trim();
const isSpecialUser = userText === '匿名用户' || userText === '知乎管理员';
const userPrefix = isSpecialUser ? '' : '用户:';
const timelineItem = `
${timeText}
${logId ? `${logId}` : ''}
${contentSections}
${reasonText ? `
` : ''}
`;
// 存储日志数据
logItemsData.push({
html: timelineItem,
time: timeText
});
});
// 根据升序标志调整顺序
let sortedData = logItemsData;
if (asc_flag === 0) {
// 降序:保持原顺序(最新的在最前面)- 知乎默认顺序
// 不需要做任何操作
} else {
// 升序:反转顺序(最旧的在最前面)
sortedData = [...logItemsData].reverse();
}
// 将排序后的条目添加到时间轴
sortedData.forEach(item => {
timelineContainer.find('#timeline-content').append(item.html);
});
// 替换原内容
logListWrap.replaceWith(timelineContainer);
// 设置排序功能
setupSortFunction(timelineContainer, logItemsData);
GM_addStyle(`
/* 隐藏原日志内容 */
.zm-item, #zh-question-title + h2, .zm-editable-editor-wrap, .zh-answers-title, .zu-main-sidebar {
display: none !important;
}
.zu-main-content-inner{
width:100%;
}
#zh-question-title{
margin:15px 0px;
}
.zh-backtotop .btn-action{
position:fixed;
right:30px;
bottom:50px;
}
#zh-question-title>.zm-item-title{
font-size:22px;
}
/* 时间轴样式 */
.timeline-container {
background: white;
border-radius: 12px;
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
padding: 40px;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.timeline-header {
margin-bottom: 40px;
padding-bottom: 20px;
display: flex;
justify-content: space-between;
align-items: center;
border-bottom: 1px solid #f0f2f7;
}
.timeline-title {
font-size: 20px;
font-weight: 600;
color: #1a1a1a;
margin-bottom: 8px;
}
/* 排序容器样式 */
.sort-container {
position: relative;
}
.sort-button {
display: flex;
align-items: center;
gap: 8px;
padding: 8px 16px;
background: #f6f6f6;
border: 1px solid #e7e9ed;
border-radius: 20px;
color: #8590a6;
font-size: 14px;
cursor: pointer;
transition: all 0.2s ease;
user-select: none;
}
.sort-button:hover {
background: #f0f2f7;
border-color: #c2c9d1;
}
.sort-icon {
fill: #8590a6;
transition: transform 0.2s ease;
}
.sort-dropdown {
position: absolute;
top: 100%;
right: 0;
margin-top: 8px;
background: white;
border: 1px solid #e7e9ed;
border-radius: 8px;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
min-width: 120px;
z-index: 1000;
display: none;
}
.sort-dropdown.show {
display: block;
}
.sort-option {
display: flex;
justify-content: space-between;
align-items: center;
padding: 10px 16px;
cursor: pointer;
transition: background 0.2s ease;
}
.sort-option:hover {
background: #f6f6f6;
}
.sort-option.active {
color: #0084ff;
}
.sort-check {
fill: #0084ff;
}
/* 锁定警告样式 */
.lock-warning {
background-color: #fff1f0 !important;
border-left-color: #ff4d4f !important;
}
/* 解锁成功样式(新增) */
.unlock-success {
background-color: #e7ffcf !important;
border-left-color: #52c41a !important;
}
/* 关闭警告样式(新增) */
.close-warning {
background-color: #f5f5f5 !important;
border-left-color: #d9d9d9 !important;
}
.close-warning .change-text {
font-weight: normal !important; /* 关闭操作取消加粗 */
}
.lock-icon {
display: flex;
align-items: center;
justify-content: center;
width: 24px;
height: 24px;
margin-right: 10px;
flex-shrink: 0;
}
.lock-red {
color: #ff4d4f;
}
.lock-green {
color: #52c41a;
}
.lock-gray {
color: #8c8c8c;
}
.content-change.lock-warning,
.content-change.unlock-success,
.content-change.close-warning {
display: flex;
align-items: flex-start;
}
.content-change.lock-warning .change-text,
.content-change.unlock-success .change-text,
.content-change.close-warning .change-text {
flex: 1;
}
/* 时间轴其他样式保持不变... */
.timeline-subtitle {
font-size: 16px;
color: #8590a6;
}
.timeline {
position: relative;
margin-top: 30px;
}
.timeline::before {
content: '';
position: absolute;
left: 20px;
top: 0;
bottom: 0;
width: 2px;
background: #e7e9ed;
z-index: 1;
}
.timeline-item {
position: relative;
margin-bottom: 36px;
padding-left: 50px;
min-height: 80px;
}
.timeline-dot {
position: absolute;
left: 10.5px;
top: 4px;
width: 16px;
height: 16px;
border-radius: 50%;
background: #0084ff;
border: 3px solid white;
box-shadow: 0 0 0 3px #0084ff33;
z-index: 2;
}
.timeline-time-container {
display: flex;
justify-content: space-between;
margin-bottom: 8px;
}
.timeline-time {
font-size: 14px;
font-weight: 500;
color: #0084ff;
background: #0084ff0d;
padding: 4px 12px;
border-radius: 20px;
display: inline-block;
}
.timeline-log-id {
font-size: 14px;
color: #8590a6;
background: #8590a61a;
padding: 4px 12px;
border-radius: 20px;
display: inline-block;
margin-left: 8px;
}
.timeline-content {
background: #fafbfc;
border: 1px solid #e7e9ed;
border-radius: 8px;
padding: 20px;
transition: all 0.3s ease;
}
.timeline-content:hover {
border-color: #c2c9d1;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}
.content-header {
display: flex;
justify-content: start;
align-items: center;
margin-bottom: 12px;
padding-bottom: 10px;
border-bottom: 1px solid #f0f2f7;
}
.content-title {
font-size: 16px;
font-weight: 600;
color: #1a1a1a;
}
.content-meta {
font-size: 13px;
color: #8590a6;
}
.content-meta a {
color: #0084ff;
text-decoration: none;
}
.content-meta a:hover {
text-decoration: underline;
}
.content-change {
margin-top: 12px;
padding: 12px;
background: #f0f7ff;
border-radius: 6px;
border-left: 3px solid #0084ff;
}
.change-label {
font-size: 13px;
font-weight: 500;
color: #0084ff;
margin-bottom: 6px;
}
.change-text {
font-size: 14px;
color: #1a1a1a;
line-height: 1.5;
}
.question-title {
font-weight: 600;
margin-bottom: 10px;
font-size: 15px;
}
.question-supplement {
margin-top: 12px;
padding-top: 12px;
border-top: 1px dashed #e0e0e0;
font-size: 14px;
color: #595959;
}
.supplement-separator {
height: 8px;
}
.change-text del {
color: #f56c6c;
background-color: #fef0f0;
text-decoration: line-through;
margin: 0 5px 5px 0;
padding: 1px 10px 0;
border-radius: 6px;
}
.change-text ins {
color: #3e5e00;
background-color: #adda4d;
text-decoration: none;
margin: 0 5px 5px 0;
padding: 1px 10px 0;
border-radius: 6px;
}
.content-reason {
margin-top: 10px;
padding: 10px;
background: #fff7e6;
border-radius: 6px;
border-left: 3px solid #fa8c16;
}
.reason-label {
font-size: 13px;
font-weight: 500;
color: #fa8c16;
margin-bottom: 4px;
}
.reason-text {
font-size: 14px;
color: #595959;
}
/* 暗色模式适配 */
html[data-theme="dark"] .timeline-container {
background: #1f1f23;
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}
html[data-theme="dark"] .timeline-title {
color: #e6e6e6;
}
html[data-theme="dark"] .timeline-header {
border-bottom: 1px solid #444;
}
html[data-theme="dark"] .timeline-subtitle {
color: #8a8f9d;
}
html[data-theme="dark"] .timeline::before {
background: #2d2d32;
}
html[data-theme="dark"] .timeline-dot {
background: #3a76d0;
border-color: #1f1f23;
box-shadow: 0 0 0 3px #3a76d033;
}
html[data-theme="dark"] .timeline-time {
color: #3a76d0;
background: #3a76d01a;
}
html[data-theme="dark"] .timeline-log-id {
color: #8a8f9d;
background: #8a8f9d1a;
}
html[data-theme="dark"] .timeline-content {
background: #25252a;
border-color: #2d2d32;
}
html[data-theme="dark"] .content-header {
border-bottom-color: #2d2d32;
}
html[data-theme="dark"] .content-title {
color: #e6e6e6;
}
html[data-theme="dark"] .content-meta {
color: #8a8f9d;
}
html[data-theme="dark"] .content-meta a {
color: #3a76d0;
}
html[data-theme="dark"] .content-change {
background: #2a3a5a;
}
html[data-theme="dark"] .change-text {
color: #e6e6e6;
}
html[data-theme="dark"] .question-title {
color: #e6e6e6;
}
html[data-theme="dark"] .question-supplement {
color: #a6a6a6;
border-top-color: #2d2d32;
}
html[data-theme="dark"] .change-text del {
color: #f56c6c;
background-color: #fef0f0;
}
html[data-theme="dark"] .change-text ins {
color: #3e5e00;
background-color: #adda4d;
}
html[data-theme="dark"] .content-reason {
background: #3a2b1f;
}
html[data-theme="dark"] .reason-label {
color: #fa8c16;
}
html[data-theme="dark"] .reason-text {
color: #a6a6a6;
}
/* 暗色模式下的排序按钮 */
html[data-theme="dark"] .sort-button {
background: #2d2d32;
border-color: #3d3d42;
color: #8a8f9d;
}
html[data-theme="dark"] .sort-button:hover {
background: #3d3d42;
border-color: #4d4d52;
}
html[data-theme="dark"] .sort-icon {
fill: #8a8f9d;
}
html[data-theme="dark"] .sort-dropdown {
background: #2d2d32;
border-color: #3d3d42;
}
html[data-theme="dark"] .sort-option:hover {
background: #3d3d42;
}
html[data-theme="dark"] .sort-option.active {
color: #3a76d0;
}
/* 暗色模式下的锁定警告 */
html[data-theme="dark"] .lock-warning {
background-color: #3a1f1f !important;
border-left-color: #ff4d4f !important;
}
/* 暗色模式下的解锁成功样式(新增) */
html[data-theme="dark"] .unlock-success {
background-color: #1d3711 !important;
border-left-color: #52c41a !important;
}
/* 暗色模式下的关闭警告样式(新增) */
html[data-theme="dark"] .close-warning {
background-color: #3a3a42 !important;
border-left-color: #595959 !important;
}
html[data-theme="dark"] .lock-red {
color: #ff4d4f;
}
html[data-theme="dark"] .lock-green {
color: #52c41a;
}
html[data-theme="dark"] .lock-gray {
color: #8c8c8c;
}
`);
}
}
}
// 添加排序功能
function setupSortFunction(container, logItemsData) {
const sortToggle = container.find('#sort-toggle');
const sortDropdown = container.find('#sort-dropdown');
const sortOptions = container.find('.sort-option');
const sortText = container.find('.sort-text');
const sortIcon = container.find('.sort-icon');
const timelineContent = container.find('#timeline-content');
// 显示当前选中的排序选项
sortOptions.each(function() {
const option = $(this);
const value = parseInt(option.data('value'));
const checkIcon = option.find('.sort-check');
if (value === asc_flag) {
option.addClass('active');
checkIcon.show();
} else {
option.removeClass('active');
checkIcon.hide();
}
});
// 切换下拉框显示/隐藏
sortToggle.on('click', function(e) {
e.stopPropagation();
const isShowing = sortDropdown.hasClass('show');
if (isShowing) {
sortDropdown.removeClass('show');
sortIcon.css('transform', 'rotate(0deg)');
} else {
sortDropdown.addClass('show');
sortIcon.css('transform', 'rotate(180deg)');
}
});
// 选择排序选项
sortOptions.on('click', function() {
const option = $(this);
const value = parseInt(option.data('value'));
// 如果已经是当前选项,则不执行
if (value === asc_flag) {
sortDropdown.removeClass('show');
sortIcon.css('transform', 'rotate(0deg)');
return;
}
// 更新排序标志
asc_flag = value;
// 更新按钮文本
sortText.text(value === 1 ? '升序' : '降序');
// 更新下拉框中的选中状态
sortOptions.each(function() {
const opt = $(this);
const optValue = parseInt(opt.data('value'));
const checkIcon = opt.find('.sort-check');
if (optValue === value) {
opt.addClass('active');
checkIcon.show();
} else {
opt.removeClass('active');
checkIcon.hide();
}
});
// 关闭下拉框
sortDropdown.removeClass('show');
sortIcon.css('transform', 'rotate(0deg)');
// 重新排序时间轴内容
reorderTimelineItems(container, logItemsData);
});
// 点击页面其他区域关闭下拉框
$(document).on('click', function(e) {
if (!$(e.target).closest('.sort-container').length) {
sortDropdown.removeClass('show');
sortIcon.css('transform', 'rotate(0deg)');
}
});
// 防止下拉框内的点击事件冒泡到document
sortDropdown.on('click', function(e) {
e.stopPropagation();
});
}
// 重新排序时间轴条目
function reorderTimelineItems(container, logItemsData) {
const timelineContent = container.find('#timeline-content');
// 清空当前内容
timelineContent.empty();
// 根据升序标志调整顺序
let sortedData = logItemsData;
if (asc_flag === 0) {
// 降序:保持原顺序(最新的在最前面)
sortedData = [...logItemsData];
} else {
// 升序:反转顺序(最旧的在最前面)
sortedData = [...logItemsData].reverse();
}
// 重新添加排序后的条目
sortedData.forEach(item => {
timelineContent.append(item.html);
});
}
//最近浏览
let recent_flag=0;
function recent(){
if(recent_flag==0)
{
GM_addStyle(`
/*span样式*/
.css-12wb4o1 + span{
margin: 0px 8px 0px 1px;
padding-bottom: 1.5px;
font-size: 14px;
white-space: nowrap;
}
/*问题-绿色*/
.css-12wb4o1 + span.question{
border-bottom: 2px solid #67c23a;
}
/*回答-蓝色*/
.css-12wb4o1 + span.answer{
border-bottom: 2px solid #1772f6;
}
/*视频-橙色*/
.css-12wb4o1 + span.video{
border-bottom: 2px solid #f77932;
}
/*文章-黄色*/
.css-12wb4o1 + span.p{
border-bottom: 2px solid #ffc400;
}
/*用户-粉色*/
.css-12wb4o1 + span.user{
border-bottom: 2px solid #ff6080;
}
/*想法-青色*/
.css-12wb4o1 + span.idea{
border-bottom: 2px solid #00caa6;
}
/*专栏-紫色*/
.css-12wb4o1 + span.column{
border-bottom: 2px solid #6a5ff3;
}
`);
recent_flag=1;
}
$('.css-zkfaav').each(function(){
if(!$(this).hasClass('done'))
{
let imgsrc=$(this).find('img').attr('src');
if(imgsrc=='https://picx.zhimg.com/80/v2-0139ff9927193d3052ab601ee0464a3e_1440w.png')
{
$(this).find('img').after('
问题')
}
else if(imgsrc=='https://picx.zhimg.com/80/v2-1f5a5f4aad4dec4dcbda90fa885416d7_1440w.png')
{
$(this).find('img').after('
回答')
}
else if(imgsrc=='https://pica.zhimg.com/80/v2-f62ee229cc44761e3cf8f3e4f7f429ae_1440w.png')
{
$(this).find('img').after('
视频')
}
else if(imgsrc=='https://pic1.zhimg.com/80/v2-6ecdf27cd93a8a9bb91b012c5c651b61_1440w.png')
{
$(this).find('img').after('
文章')
}
else if(imgsrc=='https://pic1.zhimg.com/80/v2-8b591da926c5bd8ad2c283f58bc5a6f2_1440w.png')
{
$(this).find('img').after('
用户')
}
else if(imgsrc=='https://pic1.zhimg.com/80/v2-05536818d4d094610bbf54c6c6821664_1440w.png')
{
$(this).find('img').after('
想法')
}
else if(imgsrc=='https://picx.zhimg.com/80/v2-70c60bf304da4cb85687bfea6daf1022_1440w.png')
{
$(this).find('img').after('
专栏')
}
$(this).addClass('done')
}
});
//最近浏览隐藏侧边栏
if (Config.currentValues.hideRecentSideBar == 1) //隐藏侧边栏并拉宽内容
{
//隐藏侧边栏
$('.css-bkewaf').hide();
$('[data-za-detail-view-path-module="RightSideBar"]').hide();
$('a[aria-label="边栏锚点"]').closest('div').hide();
//拉宽内容
$(".css-9511cm").width($(".css-8gasvh").width());
}
else if (Config.currentValues.hideRecentSideBar == 2) //隐藏侧边栏,仅水平居中内容,不拉宽
{
//隐藏侧边栏
$('.css-bkewaf').hide();
$('[data-za-detail-view-path-module="RightSideBar"]').hide();
$('a[aria-label="边栏锚点"]').closest('div').hide();
//居中内容
$(".css-8gasvh").attr("style", "display:flex;justify-content:center;");
}
}
function zhihu_settings() //知乎设置
{
}
function education() //知学堂
{
}
function kvip() //知乎知识会员
{
if($('#kvip-style').length == 0)
{
GM_addStyle(`
/*背景*/
html[data-theme="dark"] main{background:#121212;}
/*内容背景*/
html[data-theme="dark"] .css-10qsyl5{background:#191b1f;}
/*论文-背景*/
html[data-theme="dark"] .css-ivc3it{background:#191b1f;}
/*论文-标题*/
html[data-theme="dark"] .css-1fhkzns{color:#d3d3d3;}
/*论文-作者*/
html[data-theme="dark"] .css-1ftt30r{color:#d3d3d3;}
/*论文边框-背景*/
html[data-theme="dark"] .css-15f2l3u{background:#191b1f;}
/*下方背景*/
html[data-theme="dark"] .css-1kg4nkt{background:#191b1f;}
/*内容合作方*/
html[data-theme="dark"] .css-g3cnya{color:#d3d3d3;}
/*具体合作方*/
html[data-theme="dark"] .css-xlksez{color:#d3d3d3;}
/*购买须知*/
html[data-theme="dark"] .css-10t9pxk{color:#d3d3d3;}
/*试读*/
html[data-theme="dark"] .css-g3v7q4{color:#d3d3d3;}
/*底部导航栏背景*/
html[data-theme="dark"] .css-x176vb{background:#191b1f;}
/*PDF预览-标题*/
html[data-theme="dark"] .css-6vkeh{background:#191b1f;}
/*PDF预览-试读提示*/
html[data-theme="dark"] .css-836wxu{background:#191b1f;}
/*PDF预览-亮度*/
html[data-theme="dark"] .pdfViewer{filter: brightness(0.6);}
`).id='kvip-style';
}
}
function project() //AI Works项目广场
{
if($('#project-style').length == 0)
{
GM_addStyle(`
/*版本号*/
html[data-theme="dark"] .qodnZRj6bu_pjzevfzri{
color: #ebeced !important;
background-color: #444 !important;
}
/*项目边框*/
html[data-theme="dark"] .QIUfkRwm6NVheLJ3jPJH{
border: 1px solid #444!important;
}
/*项目边框-hover*/
html[data-theme="dark"] .QIUfkRwm6NVheLJ3jPJH:hover{
border: 1px solid #0084ff!important;
}
/*项目标题*/
html[data-theme="dark"] .AQqrdAfDr0IsvG_GCLK9{
color:#d3d3d3 !important;
}
/*项目占位加载-背景*/
html[data-theme="dark"] .IyJFCmW1xnpZjPNR0U_1{
background:#121212;
border:1px solid #444;
}
/*项目占位加载-内部背景*/
html[data-theme="dark"] .vxUX8A_1ui6lpUOgnpoE{
background:#c4c7ce4f;
}
/*项目占位加载-分隔线*/
html[data-theme="dark"] .LbrpuCjxAtYLTD_lIZ1p{
border-top:1px solid #444;
}
`).id='project-style';
}
}
function fiore() //盐选故事
{
if($('#fiore-style').length == 0)
{
GM_addStyle(`
/*背景*/
html[data-theme="dark"] .index-module-content_h18jH{
background:#121212;
}
/*下分割线*/
html[data-theme="dark"] .index-module-divider_NUL8l{
background:#444;
}
/*盐选榜单*/
html[data-theme="dark"] .index-module-title_OcaU2{
color:#d3d3d3;
}
/*盐选榜单-首书简介*/
html[data-theme="dark"] .index-module-background_BPd2_{
color:#ffffffd4;
}
/*盐选榜单-书名*/
html[data-theme="dark"] .index-module-title_zZBgI{
color:#d3d3d3;
}
/*盐选榜单-标签*/
html[data-theme="dark"] .index-module-description_PL34K{
color:#8590a6;
}
/*热度榜*/
html[data-theme="dark"] .index-module-tabItem_rZlOO{
color:#d3d3d3;
}
/*今日必读-换一换*/
html[data-theme="dark"] .index-module-refreshBtn_al7t9{
color:#8590a6;
}
/*今日必读-书名*/
html[data-theme="dark"] .index-module-title_qO8s1{
color:#d3d3d3;
}
/*今日必读-标签*/
html[data-theme="dark"] .index-module-tags_KfjnE{
color:#8590a6;
}
/*进站必看-书名*/
html[data-theme="dark"] .index-module-title_oK8Vf{
color:#d3d3d3;
}
/*大家在看-书名*/
html[data-theme="dark"] .index-module-title_fwxRx{
color:#d3d3d3;
}
/*大家在看-节选*/
html[data-theme="dark"] .index-module-description_K6yuA{
color:#d3d3d3;
}
/*大家在看-标签*/
html[data-theme="dark"] .index-module-labels_ssCeY{
color:#8590a6;
}
/*盐选作者平台*/
html[data-theme="dark"] .index-module-title_yVas8{
color:#d3d3d3;
}
/*盐选作者平台-背景*/
html[data-theme="dark"] .index-module-authorPlatform_pqzpe{
background:#191b1f;
border:none;
}
/*盐选作者平台-口号*/
html[data-theme="dark"] .index-module-slogan_yXk50{
color:#d3d3d3;
}
/*盐选作者平台-入驻*/
html[data-theme="dark"] .index-module-subtitle_UDHKv{
color:#8590a6;
}
/*知学堂*/
html[data-theme="dark"] .index-module-title_On25b{
color:#d3d3d3;
}
/*知学堂-背景*/
html[data-theme="dark"] .index-module-resourceSlot_bUQnJ{
background:#191b1f;
border:none;
}
`).id='fiore-style';
}
}
function market() //盐选内容
{
if($('#market-style').length == 0)
{
GM_addStyle(`
/*盐选内容-书名*/
html[data-theme=dark] h1.ManuscriptTitle-root-gcmVk {
color: #d3d3d3
}
`).id='market-style';
}
}
/*
function printValue() {
console.log('\n');
console.log('hideIndexSidebar=' + hideIndexSidebar);
console.log('hideQuestionSidebar=' + hideQuestionSidebar);
console.log('hideSearchSideBar=' + hideSearchSideBar);
console.log('hideTopicSideBar=' + hideTopicSideBar);
console.log('hideCollectionSideBar=' + hideCollectionSideBar);
//console.log('hideClubSideBar=' + hideClubSideBar);
//console.log('hideDraftSideBar=' + hideDraftSideBar);
//console.log('hideLaterSideBar=' + hideLaterSideBar);
console.log('hideProfileSidebar=' + hideProfileSidebar);
console.log('hideColumnSideBar=' + hideColumnSideBar);
console.log('hideRecommendedReading=' + hideRecommendedReading);
console.log('publishTop=' + publishTop);
console.log('GIFAutoPlay=' + GIFAutoPlay);
console.log('hoverShadow=' + hoverShadow);
console.log('blockingPictureVideo=' + blockingPictureVideo);
console.log('flowTag=' + flowTag);
console.log('prefersColorScheme=' + prefersColorScheme);
console.log('hideFeedSource=' + hideFeedSource);
console.log('\n');
}
*/
//设置框样式参考https://greasyfork.org/zh-CN/scripts/37988
/*
function settings() {
let settingHTML=`
隐藏专栏文章侧边栏
`;
$('body').append(settingHTML);
GM_addStyle(`
#settingLayer #itemlist {
display: flex;
display: -webkit-flex;
align-content: center;
align-items: center;
justify-content: center;
flex-flow: row wrap;
}
#settingLayer section {
display: grid;
float: left;
width: 200px;
padding: 10px 20px;
border-right: 1px solid #0084ff;
}
#settingLayer section:nth-of-type(3n) {
border-right: none;
}
#settingLayer .switch span {
height: 30px;
line-height: 30px;
font-size: 20px;
vertical-align: top;
}
#settingLayer .switch .checkbox {
float: right;
}
#settingLayer .checkbox {
position: relative;
display: inline-block;
}
#settingLayer .checkbox:after,
#settingLayer .checkbox:before {
-webkit-font-feature-settings: normal;
-moz-font-feature-settings: normal;
font-feature-settings: normal;
-webkit-font-kerning: auto;
font-kerning: auto;
-moz-font-language-override: normal;
font-language-override: normal;
font-stretch: normal;
font-style: normal;
font-synthesis: weight style;
font-variant: normal;
font-weight: normal;
text-rendering: auto;
}
#settingLayer .checkbox label {
width: 80px;
height: 30px;
background: #ccc;
position: relative;
display: inline-block;
border-radius: 46px;
-webkit-transition: 0.4s;
transition: 0.4s;
cursor: pointer;
}
#settingLayer .checkbox label:after {
content: "";
position: absolute;
width: 50px;
height: 50px;
border-radius: 100%;
left: 0;
top: -5px;
z-index: 2;
background: #fff;
box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);
-webkit-transition: 0.4s;
transition: 0.4s;
cursor: pointer;
}
#settingLayer .checkbox input {
display: none;
}
#settingLayer .checkbox.on label:after {
left: 40px;
}
#settingLayer .checkbox.on label {
background: #4BD865;
}
#settingLayer .switch .checkbox label {
width: 70px;
}
#settingLayer .switch .checkbox label:after {
top: 0;
width: 30px;
height: 30px;
}
#settingLayerMask {
display: none;
justify-content: center;
align-items: center;
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
background-color: rgba(0, 0, 0, .5);
z-index: 200000000;
overflow: auto;
font-family: arial, sans-serif;
min-height: 100%;
font-size: 16px;
transition: 0.5s;
opacity: 1;
user-select: none;
-moz-user-select: none;
padding-bottom: 80px;
box-sizing: border-box;
}
#settingLayer {
display: flex;
flex-wrap: wrap;
padding: 20px;
margin: 45px 25px 50px 5px;
background-color: #fff;
border-radius: 4px;
position: absolute;
width: 800px;
transition: 0.5s;
}
#settingLayer #btnEle {
position: absolute;
width: 100%;
bottom: 4px;
right: 0;
background: #fff;
border-radius: 4px;
}
#settingLayer #btnEle span {
display: inline-block;
background: #EFF4F8;
border: 1px solid #3abdc1;
margin: 12px auto 10px;
color: #3abdc1;
padding: 5px 10px;
border-radius: 4px;
cursor: pointer;
outline: none;
transition: 0.3s;
}
#settingLayer #btnEle a {
color: #999;
text-decoration: none;
}
#settingLayer #btnEle a:hover {
text-decoration: underline;
color: #ef8957;
}
#settingLayer #btnEle span.feedback:hover {
border-color: #ef8957;
}
#settingLayer #btnEle span:not(.feedback):hover {
background: #3ACBDD;
color: #fff;
}
#settingLayer #btnEle .feedback {
border-color: #aaa;
}
#settingLayer #btnEle>div {
width: 100%;
margin-bottom: -100%;
display: flex;
justify-content: space-around;
background: #EFF4F8;
border-radius: 4px;
}
#settingLayer #settings-close {
background: white;
color: #3ABDC1;
line-height: 20px;
text-align: center;
height: 20px;
width: 20px;
font-size: 20px;
padding: 10px;
border: 3px solid #3ABDC1;
border-radius: 50%;
transition: .5s;
top: -20px;
right: -20px;
position: absolute;
cursor: pointer;
}
#settingLayer #settings-close::before {
content: "\\2716";
}
#settingLayer #settings-close:hover {
background: indianred;
border-color: indianred;
color: #fff;
}
#settingLayer select {
appearance:none;
-webkit-appearance: none;
-moz-appearance:none;
height: 30px;
width: 180px;
color: #0084FF;
background: white url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAfElEQVQ4T2NkoBAwUqifYdQABixh0PL/AQMDgzyOwH3IUMOogCyHGYit/w0Y/jMcYGBg4Ecz5CMDI4MDQzXjBfwGgGRBhvxjWMDAyKAPVvyf4SIDE0MCumaQFO5obPgvwMAMdgkDw18GB4YGxg/YvDWaDvAFIpG5jOJABABKFBYRvq528AAAAABJRU5ErkJggg==") no-repeat right;
font-size: 16px;
position: relative;
display: inline-block;
border: 1px solid rgb(118, 118, 118);
border-radius: 46px;
-webkit-transition: 0.4s;
transition: 0.4s;
cursor: pointer;
padding-left: 10px;
}
html[data-theme=dark] #settingLayer{
background: #191c25;
}
html[data-theme=dark] #settingLayer #btnEle>div{
background: #25282f;
}
html[data-theme=dark] #settingLayer #settings-save{
background: #8080801c;
}
html[data-theme=dark] #settingLayer select{
background: #8080801c url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAfElEQVQ4T2NkoBAwUqifYdQABixh0PL/AQMDgzyOwH3IUMOogCyHGYit/w0Y/jMcYGBg4Ecz5CMDI4MDQzXjBfwGgGRBhvxjWMDAyKAPVvyf4SIDE0MCumaQFO5obPgvwMAMdgkDw18GB4YGxg/YvDWaDvAFIpG5jOJABABKFBYRvq528AAAAABJRU5ErkJggg==") no-repeat right;
}
html[data-theme=dark] #settingLayer option{
background: #24272f;
}
html[data-theme=dark] #settingLayer #settings-close{
background: #25282f;
}
`)
//默认隐藏
$('#settingLayerMask').hide();
//读取值
hideIndexSidebar = GM_getValue('hideIndexSidebar');
hideQuestionSidebar = GM_getValue('hideQuestionSidebar');
hideSearchSideBar = GM_getValue('hideSearchSideBar');
hideTopicSideBar = GM_getValue('hideTopicSideBar');
hideCollectionSideBar = GM_getValue('hideCollectionSideBar');
//hideClubSideBar = GM_getValue('hideClubSideBar');
//hideDraftSideBar = GM_getValue('hideDraftSideBar');
//hideLaterSideBar = GM_getValue('hideLaterSideBar');
hideProfileSidebar = GM_getValue('hideProfileSidebar');
hideColumnSideBar = GM_getValue('hideColumnSideBar');
hideRecommendedReading = GM_getValue('hideRecommendedReading');
publishTop = GM_getValue('publishTop');
GIFAutoPlay = GM_getValue('GIFAutoPlay');
hoverShadow = GM_getValue('hoverShadow');
blockingPictureVideo = GM_getValue('blockingPictureVideo');
flowTag = GM_getValue('flowTag');
prefersColorScheme = GM_getValue('prefersColorScheme');
hideFeedSource = GM_getValue('hideFeedSource');
printValue(); //输出所有设置值
//在设置界面设置相应值
$('select option').removeAttr('selected');
$('#hideIndexSidebar').val(hideIndexSidebar);
$('#hideQuestionSidebar').val(hideQuestionSidebar);
$('#hideSearchSideBar').val(hideSearchSideBar);
$('#hideTopicSideBar').val(hideTopicSideBar);
$('#hideCollectionSideBar').val(hideCollectionSideBar);
//$('#hideClubSideBar').val(hideClubSideBar);
//$('#hideDraftSideBar').val(hideDraftSideBar);
//$('#hideLaterSideBar').val(hideLaterSideBar);
$('#hideProfileSidebar').val(hideProfileSidebar);
$('#hideColumnSideBar').val(hideColumnSideBar);
$('#hideRecommendedReading').val(hideRecommendedReading);
$('#publishTop').val(publishTop);
$('#GIFAutoPlay').val(GIFAutoPlay);
$('#hoverShadow').val(hoverShadow);
$('#blockingPictureVideo').val(blockingPictureVideo);
$('#flowTag').val(flowTag);
$('#prefersColorScheme').val(prefersColorScheme);
$('#hideFeedSource').val(hideFeedSource);
$('.checkbox').each(function() {
if ($(this).find('input').val() == 1)
$(this).addClass('on');
else
$(this).removeClass('on');
});
//点击关闭按钮隐藏
$('#settings-close').click(function() {
$('#settingLayerMask').hide();
});
//按ESC键隐藏
$(document).keyup(function(e) {
if (e.key === "Escape") {
$('#settingLayerMask').hide();
}
});
//开关按钮
$('.checkbox').click(function() {
if ($(this).hasClass('on')) {
$(this).find('input').val('0');
} else {
$(this).find('input').val('1');
}
$(this).toggleClass('on');
})
//保存设置
$('#settings-save').click(function() {
hideIndexSidebar = $('#hideIndexSidebar').val();
hideQuestionSidebar = $('#hideQuestionSidebar').val();
hideSearchSideBar = $('#hideSearchSideBar').val();
hideTopicSideBar = $('#hideTopicSideBar').val();
hideCollectionSideBar = $('#hideCollectionSideBar').val();
//hideClubSideBar = $('#hideClubSideBar').val();
//hideDraftSideBar = $('#hideDraftSideBar').val();
//hideLaterSideBar = $('#hideLaterSideBar').val();
hideProfileSidebar = $('#hideProfileSidebar').val();
hideColumnSideBar = $('#hideColumnSideBar').val();
hideRecommendedReading = $('#hideRecommendedReading').val();
publishTop = $('#publishTop').val();
GIFAutoPlay = $('#GIFAutoPlay').val();
hoverShadow = $('#hoverShadow').val();
blockingPictureVideo = $('#blockingPictureVideo').val();
flowTag = $('#flowTag').val();
prefersColorScheme = $('#prefersColorScheme').val();
hideFeedSource = $('#hideFeedSource').val();
GM_setValue('hideIndexSidebar', hideIndexSidebar);
GM_setValue('hideQuestionSidebar', hideQuestionSidebar);
GM_setValue('hideSearchSideBar', hideSearchSideBar);
GM_setValue('hideTopicSideBar', hideTopicSideBar);
GM_setValue('hideCollectionSideBar', hideCollectionSideBar);
//GM_setValue('hideClubSideBar', hideClubSideBar);
//GM_setValue('hideDraftSideBar', hideDraftSideBar);
//GM_setValue('hideLaterSideBar', hideLaterSideBar);
GM_setValue('hideProfileSidebar', hideProfileSidebar);
GM_setValue('hideColumnSideBar', hideColumnSideBar);
GM_setValue('hideRecommendedReading', hideRecommendedReading);
GM_setValue('publishTop', publishTop);
GM_setValue('GIFAutoPlay', GIFAutoPlay);
GM_setValue('hoverShadow', hoverShadow);
GM_setValue('blockingPictureVideo', blockingPictureVideo);
GM_setValue('flowTag', flowTag);
GM_setValue('prefersColorScheme', prefersColorScheme);
GM_setValue('hideFeedSource', hideFeedSource);
$('#settingLayerMask').hide(); //隐藏设置
window.location.reload(); //刷新当前页面.
});
}
*/
/*
function clearValue() {
GM_deleteValue('hideIndexSidebar');
GM_deleteValue('hideQuestionSidebar');
GM_deleteValue('hideSearchSideBar');
GM_deleteValue('hideTopicSideBar');
GM_deleteValue('hideCollectionSideBar');
//GM_deleteValue('hideClubSideBar');
//GM_deleteValue('hideDraftSideBar');
//GM_deleteValue('hideLaterSideBar');
GM_deleteValue('hideProfileSidebar');
GM_deleteValue('hideColumnSideBar');
GM_deleteValue('hideRecommendedReading');
GM_deleteValue('publishTop');
GM_deleteValue('GIFAutoPlay');
GM_deleteValue('hoverShadow');
GM_deleteValue('blockingPictureVideo');
GM_deleteValue('flowTag');
GM_deleteValue('prefersColorScheme');
GM_deleteValue('hideFeedSource');
}
*/
// 设置界面
function settings() {
const settingHTML = Config.generateSettingsHTML();
$('body').append(settingHTML);
GM_addStyle(`
/* 修改3:选项列表容器(每个分类一个),固定高度 + 内部滚动 */
#settingLayer .itemlist {
overflow-y: auto; /* 内容超出时本列表内部滚动 */
overflow-x: hidden; /* 禁止横向滚动 */
display: flex;
align-content: flex-start;
align-items: flex-start;
justify-content: flex-start;
gap: 8px;
flex-flow: row wrap;
height: 360px; /* 固定高度:切换分类时弹窗整体高度完全不变 */
max-height: calc(85vh - 200px); /* 扣掉页签 + 按钮,视口偏矮时自动收缩并在本列表内滚动 */
padding-bottom: 4px;
}
/* 顶部分类页签 */
#settingTabs {
display: flex;
flex-wrap: wrap;
gap: 6px;
width: 100%;
padding-bottom: 10px;
margin-bottom: 12px;
border-bottom: 1px solid #e6e6e6;
}
#settingLayer .settingTab {
font-size: 15px;
line-height: 28px;
padding: 0 12px;
border-radius: 15px;
cursor: pointer;
color: #4a5568;
background: #f2f5f9;
-webkit-transition: 0.2s;
transition: 0.2s;
user-select: none;
-webkit-user-select: none;
}
#settingLayer .settingTab:hover {
background: #e2ebf7;
}
#settingLayer .settingTab.active {
background: #0084FF;
color: #fff;
}
#settingGroups {
width: 100%;
}
/* 同一时刻只有一个分类在渲染树里:两栏重叠在物理上不可能发生 */
#settingLayer .settingGroup {
display: none;
}
#settingLayer .settingGroup.active {
display: block;
}
/* 单个配置项卡片:填充式,不描边 */
#settingLayer section {
display: grid;
float: left;
width: calc((100% - 24px) / 4); /* 每行 4 个:3 个 8px 间距共 24px,卡片宽度随容器自适应 */
padding: 10px;
background: #f6f8fb; /* 用底色区分卡片,取代原来那圈 1px 描边 */
border: 1px solid transparent; /* 预留边框位:悬停时才浮出,避免 hover 时卡片尺寸跳动 */
border-radius: 8px;
box-sizing: border-box;
-webkit-transition: background-color .15s, border-color .15s;
transition: background-color .15s, border-color .15s;
}
#settingLayer section:hover {
background: #eef3f9;
border-color: #dbe6f3;
}
#settingLayer .switch span {
height: auto;
line-height: 20px;
font-size: 15px;
vertical-align: top;
}
#settingLayer .switch .checkbox {
float: right;
}
#settingLayer .checkbox {
position: relative;
display: inline-block;
}
#settingLayer .checkbox:after,
#settingLayer .checkbox:before {
-webkit-font-feature-settings: normal;
-moz-font-feature-settings: normal;
font-feature-settings: normal;
-webkit-font-kerning: auto;
font-kerning: auto;
-moz-font-language-override: normal;
font-language-override: normal;
font-stretch: normal;
font-style: normal;
font-synthesis: weight style;
font-variant: normal;
font-weight: normal;
text-rendering: auto;
}
#settingLayer .checkbox label {
width: 80px;
height: 30px;
background: #ccc;
position: relative;
display: inline-block;
border-radius: 46px;
-webkit-transition: 0.4s;
transition: 0.4s;
cursor: pointer;
}
#settingLayer .checkbox label:after {
content: "";
position: absolute;
width: 50px;
height: 50px;
border-radius: 100%;
left: 0;
top: -5px;
z-index: 2;
background: #fff;
box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);
-webkit-transition: 0.4s;
transition: 0.4s;
cursor: pointer;
}
#settingLayer .checkbox input {
display: none;
}
#settingLayer .checkbox.on label:after {
left: 40px;
}
#settingLayer .checkbox.on label {
background: #4BD865;
}
#settingLayer .switch .checkbox label {
width: 44px;
height: 20px;
}
#settingLayer .switch .checkbox label:after {
top: 2px;
left: 2px;
width: 16px;
height: 16px;
}
#settingLayer .switch .checkbox.on label:after {
left: 26px;
}
/* 弹出层 */
/* 修改1:遮罩层,禁止自身滚动,避免双滚动条 */
#settingLayerMask {
display: none;
justify-content: center;
align-items: center;
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
background-color: rgba(0, 0, 0, .5);
z-index: 200000000;
overflow: hidden; /* 原 overflow: auto 改 hidden */
font-family: arial, sans-serif;
min-height: 100%;
font-size: 16px;
transition: 0.5s;
opacity: 1;
user-select: none;
-moz-user-select: none;
padding-bottom: 0; /* 原 80px 改 0 */
box-sizing: border-box;
}
/* 修改2:设置层,弹性列布局,限制高度,不再绝对定位 */
#settingLayer {
display: flex;
flex-direction: column; /* 新增:垂直排列 */
flex-wrap: nowrap; /* 新增:禁止换行 */
flex-shrink: 0; /* 新增:保持固定宽度,不被挤压 */
padding: 20px 20px 0 20px;
margin: 0 auto; /* 水平居中,替换原 margin */
background-color: #fff;
border-radius: 4px;
position: relative; /* 改为相对定位,用于关闭按钮 */
width: 800px;
max-height: 85vh; /* 新增:最高占视口85% */
transition: 0.5s;
}
/* 修改4:按钮容器,跟随文档流,不再绝对定位 */
#settingLayer #btnEle {
position: static; /* 原 absolute 改 static */
width: auto; /* 用负边距撑开,宽度自动计算 */
margin: 20px -20px 0 -20px; /* 上边距与列表留出20px,左右各-20px抵消父padding */
background: #fff;
height: 60px; /* 固定高度,便于计算 */
border-radius: 0 0 4px 4px; /* 下方圆角补偿,与设置层顶部圆角呼应 */
}
#settingLayer #btnEle span {
display: inline-block;
background: #EFF4F8;
border: 1px solid #3abdc1;
margin: 12px auto 10px;
color: #3abdc1;
padding: 5px 10px;
border-radius: 4px;
cursor: pointer;
outline: none;
transition: 0.3s;
}
#settingLayer #btnEle a {
color: #999;
text-decoration: none;
}
#settingLayer #btnEle a:hover {
text-decoration: underline;
color: #ef8957;
}
#settingLayer #btnEle span.feedback:hover {
border-color: #ef8957;
}
#settingLayer #btnEle span:not(.feedback):hover {
background: #3ACBDD;
color: #fff;
}
#settingLayer #btnEle .feedback {
border-color: #aaa;
}
/* 修改5:按钮所在行容器,移除负边距(否则可能错位) */
#settingLayer #btnEle > div {
width: 100%;
margin-bottom: 0; /* 原 -100% 改 0 */
display: flex;
justify-content: space-around;
background: #EFF4F8;
border-radius: 0 0 4px 4px; /* 与父级一致,保持底部圆角 */
}
/*close button*/
/* 修改6:关闭按钮,调整定位,确保不被裁剪 */
#settingLayer #settings-close {
background: white;
color: #3ABDC1;
line-height: 20px;
text-align: center;
height: 20px;
width: 20px;
font-size: 20px;
padding: 10px;
border: 3px solid #3ABDC1;
border-radius: 50%;
transition: .5s;
top: -15px; /* 微调位置,避免溢出遮罩 */
right: -15px;
position: absolute;
cursor: pointer;
z-index: 2; /* 新增:置于最前 */
}
#settingLayer #settings-close::before {
content: "\\2716";
}
#settingLayer #settings-close:hover {
background: indianred;
border-color: indianred;
color: #fff;
}
#settingLayer select {
appearance:none;
-webkit-appearance: none;
-moz-appearance:none;
height: 30px;
width: 180px;
color: #0084FF;
background: white url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAfElEQVQ4T2NkoBAwUqifYdQABixh0PL/AQMDgzyOwH3IUMOogCyHGYit/w0Y/jMcYGBg4Ecz5CMDI4MDQzXjBfwGgGRBhvxjWMDAyKAPVvyf4SIDE0MCumaQFO5obPgvwMAMdgkDw18GB4YGxg/YvDWaDvAFIpG5jOJABABKFBYRvq528AAAAABJRU5ErkJggg==") no-repeat right;
font-size: 16px;
position: relative;
display: inline-block;
border: 1px solid rgb(118, 118, 118);
border-radius: 46px;
-webkit-transition: 0.4s;
transition: 0.4s;
cursor: pointer;
padding-left: 10px;
}
html[data-theme=dark] #settingLayer{
background: #191c25;
}
html[data-theme=dark] #settingLayer #btnEle {
background: #25282f; /* 与内部 div 背景相同 */
}
html[data-theme=dark] #settingLayer #btnEle>div{
background: #25282f;
}
html[data-theme=dark] #settingLayer #settings-save{
background: #8080801c;
}
html[data-theme=dark] #settingLayer select{
background: #8080801c url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAfElEQVQ4T2NkoBAwUqifYdQABixh0PL/AQMDgzyOwH3IUMOogCyHGYit/w0Y/jMcYGBg4Ecz5CMDI4MDQzXjBfwGgGRBhvxjWMDAyKAPVvyf4SIDE0MCumaQFO5obPgvwMAMdgkDw18GB4YGxg/YvDWaDvAFIpG5jOJABABKFBYRvq528AAAAABJRU5ErkJggg==") no-repeat right;
}
html[data-theme=dark] #settingLayer option{
background: #24272f;
}
html[data-theme=dark] #settingLayer #settings-close{
background: #25282f;
}
html[data-theme=dark] #settingLayer .settingTab {
background: #24272f;
color: #b8bfcc;
}
html[data-theme=dark] #settingLayer .settingTab:hover {
background: #2e323c;
}
html[data-theme=dark] #settingLayer .settingTab.active {
background: #0084FF;
color: #fff;
}
html[data-theme=dark] #settingTabs {
border-bottom-color: #3a3f4b;
}
html[data-theme=dark] #settingLayer section {
border-color: #3a3f4b;
}
/* ============ 字号 + 控件尺寸(后置覆盖上方旧值,故放在最后) ============ */
#settingLayerMask {
font-size: 15px;
}
#settingLayer {
width: 840px; /* 800 → 840:15px 字号下每行 4 个的卡片由 186px 变 196px,
给下拉框右侧箭头腾出位置,选项文字才不会被截断 */
padding: 14px 16px 0 16px;
transition: none; /* 关掉上面的 transition: 0.5s(= transition: all):否则容器高度变化会被做成动画,
切分类时新内容已经渲染、旧动画仍在跑,看起来就是「两栏重叠」 */
}
#settingLayer select {
-webkit-appearance: none;
appearance: none;
height: 30px;
width: 100%;
box-sizing: border-box; /* 宽度 100% 含内边距与边框,文字区宽度才可预期 */
font-size: 15px;
color: #2b3440;
background: #fff url("data:image/svg+xml;charset=utf-8,
") no-repeat right 8px center;
background-size: 12px 12px;
border: 1px solid #e3e8ee;
border-radius: 8px;
padding: 0 24px 0 8px; /* 右侧 24px 留给箭头:15px 的「隐藏,拉宽显示内容」需 135px,卡片实得 140px */
cursor: pointer;
-webkit-transition: border-color .15s, box-shadow .15s;
transition: border-color .15s, box-shadow .15s;
}
#settingLayer select:hover {
border-color: #c9d6e5;
}
#settingLayer select:focus {
outline: none;
border-color: #0084FF;
box-shadow: 0 0 0 3px rgba(0, 132, 255, .12);
}
#settingLayer #btnEle {
height: 50px;
margin: 12px -16px 0 -16px;
}
#settingLayer #btnEle span {
font-size: 15px;
padding: 4px 12px;
}
#settingLayer #settings-close {
font-size: 17px;
line-height: 20px;
height: 20px;
width: 20px;
padding: 8px;
}
/* ---- 暗色模式:新卡片 / 新下拉框 ----
旧暗色规则(html[data-theme=dark] #settingLayer section / select)特异性比上面的基础规则高,
必须成对给出同样特异性的暗色版本,靠源码顺序(更靠后)胜出。
注意::hover 规则要比非 hover 的暗色规则再多一个伪类才压得住,故写成 select:hover / section:hover。 */
html[data-theme=dark] #settingLayer section {
background: #1f232b;
border-color: transparent;
}
html[data-theme=dark] #settingLayer section:hover {
background: #262b34;
border-color: #3a3f4b;
}
html[data-theme=dark] #settingLayer select {
color: #dfe3ea;
border-color: #3a3f4b;
/* background 简写会顺带把 background-size 重置成 auto,所以必须在其后重新声明一次 */
background: #24272f url("data:image/svg+xml;charset=utf-8,
") no-repeat right 8px center;
background-size: 12px 12px;
}
html[data-theme=dark] #settingLayer select:hover {
border-color: #505a6b;
}
`);
// 默认隐藏
$('#settingLayerMask').hide();
Config.printValue();
// 开关按钮
$('.checkbox').click(function () {
if ($(this).hasClass('on')) {
$(this).find('input').val('0');
} else {
$(this).find('input').val('1');
}
$(this).toggleClass('on');
});
// 点击关闭按钮隐藏
$('#settings-close').click(function () {
$('#settingLayerMask').hide();
});
// 按 ESC 键隐藏
$(document).keyup(function (e) {
if (e.key === "Escape") {
$('#settingLayerMask').hide();
}
});
// 顶部页签:切换分类
$('#settingTabs').on('click', '.settingTab', function () {
const groupKey = $(this).data('group');
$('#settingTabs .settingTab').removeClass('active');
$(this).addClass('active');
$('#settingGroups .settingGroup').removeClass('active');
$('#settingGroups .settingGroup[data-group="' + groupKey + '"]').addClass('active');
});
// 保存设置
$('#settings-save').click(() => {
Config.saveSettings();
});
}
(function() {
'use strict';
/*
//根据当前cookie,判断是否设置夜间模式
if ($.cookie('nightmode') != undefined) {
if ($.cookie('nightmode') == 1) {
$("html").attr("data-theme", "dark");
$(".ightmode").find("img").attr("src", light).attr("style", "vertical-align:middle; width:20px; height:20px;");
$(".nightmode").find("span").text(" 日间模式");
} else {
$("html").attr("data-theme", "light");
$(".nightmode").find("img").attr("src", dark).attr("style", "vertical-align:middle; width:18px; height:18px;");
$(".nightmode").find("span").text(" 夜间模式");
}
}
*/
// 根据存储的值设置初始主题
var nightmodeValue = GM_getValue('nightmode');
if (nightmodeValue == 1) {
$("html").attr("data-theme", "dark");
$(".nightmode").find("img").attr("src", light).attr("style", "vertical-align:middle; width:20px; height:20px;");
$(".nightmode").each(function() {
if ($(this).find("span").text().indexOf(" 日间模式") == -1)
$(this).find("span").text(" 日间模式");
});
} else {
$("html").attr("data-theme", "light");
$(".nightmode").find("img").attr("src", dark).attr("style", "vertical-align:middle; width:18px; height:18px;");
$(".nightmode").each(function() {
if ($(this).find("span").text().indexOf(" 夜间模式") == -1)
$(this).find("span").text(" 夜间模式");
});
}
$('head').append(`
`);
//clearValue(); //清空所有设置值
/*
//设置默认值
if (GM_getValue('hideIndexSidebar') == undefined) {
GM_setValue('hideIndexSidebar', '1');
}
if (GM_getValue('hideQuestionSidebar') == undefined) {
GM_setValue('hideQuestionSidebar', '1');
}
if (GM_getValue('hideSearchSideBar') == undefined) {
GM_setValue('hideSearchSideBar', '1');
}
if (GM_getValue('hideTopicSideBar') == undefined) {
GM_setValue('hideTopicSideBar', '1');
}
if (GM_getValue('hideCollectionSideBar') == undefined) {
GM_setValue('hideCollectionSideBar', '1');
}
*/
/*
if (GM_getValue('hideClubSideBar') == undefined) {
GM_setValue('hideClubSideBar', '1');
}
if (GM_getValue('hideDraftSideBar') == undefined) {
GM_setValue('hideDraftSideBar', '1');
}
if (GM_getValue('hideLaterSideBar') == undefined) {
GM_setValue('hideLaterSideBar', '1');
}
*/
/*
if (GM_getValue('hideProfileSidebar') == undefined) {
GM_setValue('hideProfileSidebar', '0');
}
if (GM_getValue('hideColumnSideBar') == undefined) {
GM_setValue('hideColumnSideBar', '1');
}
if (GM_getValue('hideRecommendedReading') == undefined) {
GM_setValue('hideRecommendedReading', '1');
}
if (GM_getValue('publishTop') == undefined) {
GM_setValue('publishTop', '1');
}
if (GM_getValue('GIFAutoPlay') == undefined) {
GM_setValue('GIFAutoPlay', '0');
}
if (GM_getValue('hoverShadow') == undefined) {
GM_setValue('hoverShadow', '1');
}
if (GM_getValue('blockingPictureVideo') == undefined) {
GM_setValue('blockingPictureVideo', '0');
}
if (GM_getValue('flowTag') == undefined) {
GM_setValue('flowTag', '0');
}
if (GM_getValue('prefersColorScheme') == undefined) {
GM_setValue('prefersColorScheme', '0');
}
if (GM_getValue('hideFeedSource') == undefined) {
GM_setValue('hideFeedSource', '1');
}
*/
/*
//恢复默认设置
Config.clearValue();
Config.initConfig();
*/
//设置界面
settings();
//页面内的设置入口(左下角悬浮齿轮,挂在 body 上,不受知乎路由重渲染影响)
addSettingsEntry();
//注册设置按钮
GM_registerMenuCommand("知乎 美化 设置", function() {
$('#settingLayerMask').show();
});
//添加自定义CSS
addCSS();
//全局功能函数
setInterval(directLink, 100);
setInterval(iconColor, 100);
setInterval(originalPic, 100);
setInterval(gifPlaying, 100);
//清空搜索框占位符
setInterval(function() {
$(".SearchBar-input input").attr("placeholder", "");
}, 100);
//折叠谢邀
let timer = setInterval(function() {
if ($(".QuestionInvitation-content").text().indexOf("更多推荐结果") > -1) {
clearInterval(timer);
$(".QuestionInvitation-content").addClass("hide");
$(".QuestionInvitation-content").hide();
$(".QuestionInvitation-title").html($(".QuestionInvitation-title").text() + '
(点击此处展开/折叠)');
$(".Topbar").click(function() {
if (($(".QuestionInvitation-content").hasClass("hide"))) {
$(".QuestionInvitation-content").removeClass("hide").addClass("show");
$(".QuestionInvitation-content").show();
} else {
$(".QuestionInvitation-content").removeClass("show").addClass("hide");
$(".QuestionInvitation-content").hide();
}
});
}
}, 100);
//剪切板仅保留选中内容
//代码来源:https://greasyfork.org/scripts/367724
function addLink(e) {
e.preventDefault();
var copytext = window.getSelection().toString();
var clipdata = e.clipboardData || window.clipboardData;
if (clipdata) {
clipdata.setData('Text', copytext);
}
}
document.addEventListener('copy', addLink);
/*
//每个页面对应的功能函数
if (window.location.href.indexOf("/topic/") > -1) //话题页
setInterval(topic, 300);
else if (window.location.href.indexOf("/log") > -1)//问题日志
setInterval(question_log, 300);
else if (window.location.href.indexOf("/question/") > -1) //回答页
setInterval(question, 300);
else if (window.location.href.indexOf("/zvideo/") > -1) //知乎视频页
setInterval(zvideo, 300);
//else if (window.location.href.indexOf("/club/") > -1) //知乎圈子页
// setInterval(club, 300);
else if (window.location.href.indexOf("/ring/") > -1 || window.location.href.indexOf("/ring-feeds") > -1) //知乎圈子页
setInterval(ring, 300);
else if (window.location.href.indexOf("/search") > -1) //搜索结果页
setInterval(search, 300);
else if (window.location.href.indexOf("/lives") > -1) //知乎讲座页
setInterval(lives, 300);
else if (window.location.href.indexOf("/collection/") > -1) //收藏夹
setInterval(collection, 300);
else if (window.location.href.indexOf("zhuanlan.") > -1) //专栏文章
setInterval(zhuanlan, 300);
else if (window.location.href.indexOf("/pin/") > -1) //想法
setInterval(pin, 300);
else if (window.location.href.indexOf("/people/") > -1 || window.location.href.indexOf("/org/") > -1) //用户主页
setInterval(people, 300);
//else if (window.location.href.indexOf("/draft") > -1) //草稿页
// setInterval(draft, 300);
else if (window.location.href.indexOf("/roundtable/") > -1) //知乎圆桌页
setInterval(roundtable, 300);
else if (window.location.href.indexOf("/column/") > -1) //专栏列表
setInterval(column, 300);
else if (window.location.href.indexOf("cheese.") > -1) //芝士平台
setInterval(cheese, 300);
//else if (window.location.href.indexOf("/xen/") > -1 || window.location.href.indexOf("/remix/") > -1) //盐选专栏、知乎讲书
// setInterval(xen, 300);
else if (window.location.href.indexOf("/creator") > -1) //创作中心
setInterval(creator, 300);
else if (window.location.href.indexOf("/wza/") > -1) //无障碍说明
setInterval(wza, 300);
else if (window.location.href.indexOf("/recent-viewed") > -1) //最近浏览
setInterval(recent, 300);
else if (window.location.href.indexOf("/settings") > -1) //知乎设置
setInterval(zhihu_settings, 300);
else
setInterval(index, 300); //首页
*/
/**
* ============================================================================
* 第二部分:页面观察基类 (PageObserver)
* 负责:URL 变更监测、DOM 节点监听、3 秒逻辑兜底
* ============================================================================
*/
class PageObserver {
constructor() {
this.currentPath = ""; // 记录当前页面 URL,防止重复触发
this.observer = null; // MutationObserver 实例
this.fallbackTimer = null; // 兜底定时器
this.initRouter(); // 初始化 URL 变更监听
}
/**
* 监听 URL 变化:适配知乎这种单页应用 (SPA)
* 劫持 pushState/replaceState 并监听 popstate 事件
*/
initRouter() {
const self = this;
const _pushState = history.pushState;
const _replaceState = history.replaceState;
// 劫持跳转方法
history.pushState = function() {
_pushState.apply(this, arguments);
self.onUrlChange();
};
history.replaceState = function() {
_replaceState.apply(this, arguments);
self.onUrlChange();
};
// 监听浏览器前进/后退
window.addEventListener('popstate', () => self.onUrlChange());
// 脚本首次加载时手动执行一次
this.onUrlChange();
}
/**
* 当 URL 发生变化时的核心逻辑
*/
onUrlChange() {
const path = window.location.href;
// 如果 URL 没变(仅仅是 hash 变化等),则不处理
if (path === this.currentPath) return;
this.currentPath = path;
// 切换页面时,必须断开之前的观察器并清除之前的兜底定时器
if (this.observer) {
this.observer.disconnect();
this.observer = null;
}
if (this.fallbackTimer) {
clearTimeout(this.fallbackTimer);
this.fallbackTimer = null;
}
// 执行子类实现的具体分发逻辑
this.run();
}
/**
* 增强版监听:
* @param {string} selector - 根容器选择器
* @param {function} callback - 执行函数
* @param {boolean} persistent - 是否持续监听(针对信息流页面)
*/
observeSelector(selector, callback, persistent = false) {
let isFirstMatch = true;
let lastTriggerTime = 0; // 用于节流
const execute = () => {
// 简单的节流:防止 MutationObserver 在 500ms 内疯狂触发
const now = Date.now();
if (now - lastTriggerTime < 500) return;
lastTriggerTime = now;
callback();
// 如果不是持续监听,执行一次后就断开
if (!persistent) {
if (this.observer) this.observer.disconnect();
if (this.fallbackTimer) clearTimeout(this.fallbackTimer);
}
};
// 1. 立即检查
if (document.querySelector(selector)) {
execute();
if (!persistent) return;
}
// 2. 兜底(仅针对第一次进入页面)
this.fallbackTimer = setTimeout(() => {
if (isFirstMatch) {
console.warn(`[兜底] 未监测到节点 ${selector},已强制执行函数 ${callback}`);
execute();
}
}, 3000);
// 3. 监听 DOM
this.observer = new MutationObserver((mutations) => {
if (document.querySelector(selector)) {
isFirstMatch = false;
execute();
}
});
this.observer.observe(document.body, { childList: true, subtree: true });
}
}
/**
* ============================================================================
* 第三部分:知乎逻辑分发类 (ZhihuPageHandler)
* 负责:定义所有知乎页面的 URL 匹配及对应的渲染函数
* ============================================================================
*/
class ZhihuPageHandler extends PageObserver {
/**
* 核心分发逻辑:根据当前 URL 决定监听哪个节点,并触发哪个函数
*/
run() {
// ============ 新增:死链接重定向 ============
const path = window.location.pathname;
const deadMatch = path.match(/^\/video\/immersion\/feed\/(\d+)/);
if (deadMatch) {
const videoId = deadMatch[1];
const newUrl = 'https://www.zhihu.com/zvideo/' + videoId;
window.location.replace(newUrl);
return; // 立即停止后续逻辑
}
// ============================================
const url = this.currentPath;
/*
// 全局操作:每当 URL 变化,优先注入一次通用样式
if (typeof addCommonCSS === 'function') {
addCommonCSS();
}
*/
// --- 路由匹配分发 ---
// 1. 问题日志(Log)
if (url.includes("/log")) {
this.observeSelector('.zu-main-content', () => question_log(), true);
}
// 2. 回答详情页 (Question)
else if (url.includes("/question/")) {
this.observeSelector('.QuestionPage', () => question(), true);
}
// 3. 搜索结果页 (Search)
else if (url.includes("/search")) {
this.observeSelector('.SearchMain', () => search(), true);
}
// 4. 话题页 (Topic)
else if (url.includes("/topic/")) {
this.observeSelector('.TopicMain', () => topic(),true);
}
// 5. 收藏夹 (Collection)
else if (url.includes("/collection/") || url.includes("/collections/")) {
this.observeSelector('.CollectionsDetailPage, .Collections-container', () => collection(), true);
}
// 6. 专栏列表 (Column)
else if (url.includes("/column/")) {
this.observeSelector('.App-main', () => column(), true);
}
// 7. 专栏文章 (Zhuanlan)
else if (url.includes("zhuanlan.")) {
this.observeSelector('.Post-content', () => zhuanlan(), true);
}
// 8. 用户主页 / 机构号主页 (People / Org)
else if (url.includes("/people/") || url.includes("/org/")) {
this.observeSelector('.Profile-main', () => people(), true);
}
// 9. 想法页面 (Pin)
else if (url.includes("/pin/")) {
this.observeSelector('.PinDetail', () => pin(),true);
}
// 10. 圆桌(Roundtable)
else if (url.includes("/roundtable/")) {
this.observeSelector('ul[role="tablist"]', () => roundtable(), true);
}
// 11. 芝士平台(Cheese)
else if (url.includes("cheese.")) {
this.observeSelector('#root', () => cheese(), false);
}
// 12. 视频页(Zvideo)
else if (url.includes("/zvideo/")) {
this.observeSelector('.ZVideo', () => zvideo(), true);
}
// 13. 创作中心(Creator)
else if (url.includes("/creator")) {
this.observeSelector('.Creator', () => creator(), true);
}
// 14. 圈子(Ring)
else if (url.includes("/ring/") || url.includes("/ring-feeds")) {
this.observeSelector('.css-14pitda, .Topstory-container', () => ring(), true);
}
// 15. 讲座(Lives)
else if (url.includes("/lives")) {
this.observeSelector('[class*="LiveDetailsPage"]', () => lives(), true);
}
// 16. 无障碍说明(Wza)
else if (url.includes("/wza/")) {
this.observeSelector('.content', () => wza(), false);
}
// 17. 最近浏览(Recent)
else if (url.includes("/recent-viewed")) {
this.observeSelector('main', () => recent(), true);
}
// 18. 知乎设置(Settings)
else if (url.includes("/settings")) {
this.observeSelector('.SettingsMain', () => zhihu_settings(), false);
}
// 19. 知学堂(Education)
else if (url.includes("/education")) {
this.observeSelector('#app', () => education(), true);
}
// 20. 知乎知识会员(Kvip)
else if (url.includes("/kvip/")) {
this.observeSelector('#App', () => kvip(), true);
}
// 21. AI Works项目广场(Project)
else if (url.includes("/project/") || url.includes("/project-square") ) {
this.observeSelector('main', () => project(), true);
}
// 22. 盐选故事(Fiore)
else if (url.includes("/fiore/")) {
this.observeSelector('#app', () => fiore(), true);
}
// 22. 盐选内容(Market)
else if (url.includes("/market/")) {
this.observeSelector('#app', () => market(), true);
}
// X. 默认情况:首页 (Topstory)
else {
// 如果不在上述特定路径,则默认当作首页处理
// 监听 Topstory 类,确保首页逻辑 index() 执行
this.observeSelector('.Topstory', () => index(), true);
}
}
}
// 最后一步:实例化启动
const Handler = new ZhihuPageHandler();
})();