Skip to content

Instantly share code, notes, and snippets.

@giiska
Created June 22, 2019 03:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save giiska/022c9f3af686f7cb8044d1b42c68a7c9 to your computer and use it in GitHub Desktop.
Save giiska/022c9f3af686f7cb8044d1b42c68a7c9 to your computer and use it in GitHub Desktop.
顶部显示知乎专栏文章日期
// ==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