-
-
Save giiska/022c9f3af686f7cb8044d1b42c68a7c9 to your computer and use it in GitHub Desktop.
顶部显示知乎专栏文章日期
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name 顶部显示知乎专栏文章日期 | |
// @namespace http://tampermonkey.net/ | |
// @version 0.2 | |
// @description try to take over the world! | |
// @author zoffy zhang, bammoo | |
// @match https://zhuanlan.zhihu.com/* | |
// @grant none | |
// ==/UserScript== | |
(function () { | |
'use strict'; | |
var target = document.querySelector('.ContentItem-time'); | |
var date1 = target.innerText; | |
target.click(); | |
var date2 = target.innerText; | |
var newContent = `<span style="margin-right: 20px;">${date1}</span>` | |
if(date2 && (date2 !== date1)) { | |
newContent += `<span>${date2}</span>` | |
} | |
var insertPosition = document.querySelector('.Post-Title'); | |
insertPosition.insertAdjacentHTML('afterend', `<div style="margin-bottom: 15px; font-size:14px; color: #1a1a1a;">${newContent}</div>`); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment