Skip to content

Commit dd01506

Browse files
committed
新增 [显示问题作者] 功能
1 parent 8c857f2 commit dd01506

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

Zhihu-Enhanced.user.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// ==UserScript==
22
// @name 知乎增强
3-
// @version 1.9.0
3+
// @version 1.9.1
44
// @author X.I.U
5-
// @description 移除登录弹窗、屏蔽首页视频、默认收起回答、快捷收起当前回答/评论(左键两侧空白处)、快捷回到顶部(右键两侧空白处)、屏蔽用户 (发布的内容)、屏蔽关键词(标题/评论)、移除高亮链接、屏蔽盐选内容、净化标题消息、展开问题描述、置顶显示时间、完整问题时间、区分问题文章、直达问题按钮、默认高清原图、默认站外直链
5+
// @description 移除登录弹窗、屏蔽首页视频、默认收起回答、快捷收起当前回答/评论(左键两侧空白处)、快捷回到顶部(右键两侧空白处)、屏蔽用户 (发布的内容)、屏蔽关键词(标题/评论)、移除高亮链接、屏蔽盐选内容、净化标题消息、展开问题描述、显示问题作者、置顶显示时间、完整问题时间、区分问题文章、直达问题按钮、默认高清原图、默认站外直链
66
// @match *://www.zhihu.com/*
77
// @match *://zhuanlan.zhihu.com/*
88
// @icon https://static.zhihu.com/heifetz/favicon.ico
@@ -1215,6 +1215,18 @@ function addLocationchange() {
12151215
}
12161216

12171217

1218+
// 显示问题作者
1219+
function question_author() {
1220+
if (document.querySelector('.BrandQuestionSymbol, .QuestionAuthor')) return
1221+
let qJson = JSON.parse(document.querySelector('#js-initialData').textContent).initialState.entities.questions[/\d+/.exec(location.pathname)[0]].author,
1222+
html = `<div class="BrandQuestionSymbol"><a class="BrandQuestionSymbol-brandLink" href="/people/${qJson.urlToken}"><img role="presentation" src="${qJson.avatarUrl}" class="BrandQuestionSymbol-logo" alt=""><span class="BrandQuestionSymbol-name">${qJson.name}</span></a><span>的提问</span><div class="BrandQuestionSymbol-divider"></div></div>`;
1223+
//html2 = `<div class="QuestionAuthor"><div class="AuthorInfo AuthorInfo--plain" itemprop="author" itemscope="" itemtype="http://schema.org/Person"><div class="AuthorInfo"><span class="UserLink AuthorInfo-avatarWrapper"><div class="Popover"><div id="Popover18-toggle" aria-haspopup="true" aria-expanded="false" aria-owns="Popover18-content"><a class="UserLink-link" data-za-detail-view-element_name="User" target="_blank" href="${qJson.urlToken}"><img class="Avatar AuthorInfo-avatar" width="24" height="24" src="${qJson.avatarUrl}"></a></div></div></span><div class="AuthorInfo-content"><div class="AuthorInfo-head"><span class="UserLink AuthorInfo-name"><div class="Popover"><div id="Popover19-toggle" aria-haspopup="true" aria-expanded="false" aria-owns="Popover19-content"><a class="UserLink-link" data-za-detail-view-element_name="User" target="_blank" href="${qJson.urlToken}">${qJson.name}</a></div></div></span></div></div></div></div></div>`
1224+
//console.log(qJson)
1225+
document.querySelector('.QuestionHeader-topics').insertAdjacentHTML('beforebegin', html);
1226+
//document.querySelector('.QuestionPage h1.QuestionHeader-title').insertAdjacentHTML('afterend', html2);
1227+
}
1228+
1229+
12181230
// [完整显示时间 + 置顶显示时间] 功能修改自:https://greasyfork.org/scripts/402808(从 JQuery 改为原生 JavaScript,且精简、优化了代码)
12191231
// 完整显示时间 + 置顶显示时间
12201232
function topTime_(css, classs) {
@@ -1360,7 +1372,7 @@ function questionInvitation(){
13601372
defaultCollapsedAnswer(); // 默认收起回答
13611373
}
13621374
setInterval(function(){topTime_('.ContentItem.AnswerItem', 'ContentItem-meta')}, 300); // 置顶显示时间
1363-
setTimeout(question_time, 300); // 问题创建时间
1375+
setTimeout(function(){question_time(); question_author()}, 100); //问题创建时间 + 显示问题作者
13641376
questionInvitation(); // 默认折叠邀请
13651377

13661378
} else if (location.pathname === '/search') { // 搜索结果页 //

0 commit comments

Comments
 (0)