创建时间:' + getUTC8(new Date(document.querySelector('.QuestionPage > meta[itemprop=dateCreated]').content)) + '
最后编辑:' + getUTC8(new Date(document.querySelector('.QuestionPage > meta[itemprop=dateModified]').content)) + '
');
}
}
// UTC 标准时转 UTC+8 北京时间,修改自:https://greasyfork.org/zh-CN/scripts/402808(精简)
function getUTC8(t) {
return (t.getFullYear() + '-' + (((t.getMonth() + 1) < 10) ? ('0' + (t.getMonth() + 1)) : (t.getMonth() + 1)) + '-' + ((t.getDate() < 10) ? ('0' + t.getDate()) : t.getDate()) + '\xa0\xa0' + ((t.getHours() < 10) ? ('0' + t.getHours()) : t.getHours()) + ':' + ((t.getMinutes() < 10) ? ('0' + t.getMinutes()) : t.getMinutes()) + ':' + ((t.getSeconds() < 10) ? ('0' + t.getSeconds()) : t.getSeconds()));
}
// 默认高清原图(无水印)
function originalPic(){
document.querySelectorAll('img[data-original][data-original-token][data-lazy-status]:not([data-original-xiu]):not(.comment_sticker):not(.Avatar)').forEach(function(one){one.src = 'https://' + one.dataset.original.split('/')[2] + '/' + one.dataset.originalToken + '.webp'; one.dataset.originalXiu = 'true';});
}
// 默认站外直链,修改自:https://greasyfork.org/scripts/402808(从 JQuery 改为原生 JavaScript,且精简、优化了代码)
function getDirectExternalUrl(href) {
const marker = 'link.zhihu.com/?target=';
const markerIndex = href.indexOf(marker);
if (markerIndex === -1) return null
try {
const directUrl = new URL(decodeURIComponent(href.substring(markerIndex + marker.length)));
if (directUrl.protocol !== 'http:' && directUrl.protocol !== 'https:') return null
return directUrl.href;
} catch (error) {
return null
}
}
function directLink () {
document.querySelectorAll('a.external[href*="link.zhihu.com/?target="], a.LinkCard[href*="link.zhihu.com/?target="]:not(.MCNLinkCard):not(.ZVideoLinkCard):not(.ADLinkCardContainer)').forEach(function (_this) {
const directUrl = getDirectExternalUrl(_this.href);
if (directUrl) _this.href = directUrl;
});
}
// 默认折叠邀请,修改自:https://greasyfork.org/scripts/402808(从 JQuery 改为原生 JavaScript,且精简、优化了代码)
function questionInvitation(){
let time = setInterval(function(){
let q = document.querySelector('.QuestionInvitation-content'); if (!q) return
clearInterval(time);
q.style.display = 'none';
document.querySelector('.QuestionInvitation-title').innerHTML = document.querySelector('.QuestionInvitation-title').innerText + '