Skip to content

Instantly share code, notes, and snippets.

@giiska
Created June 22, 2019 03:37
Show Gist options
  • Select an option

  • Save giiska/022c9f3af686f7cb8044d1b42c68a7c9 to your computer and use it in GitHub Desktop.

Select an option

Save giiska/022c9f3af686f7cb8044d1b42c68a7c9 to your computer and use it in GitHub Desktop.

Revisions

  1. 肖建锋 created this gist Jun 22, 2019.
    24 changes: 24 additions & 0 deletions 1.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    // ==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>`);
    })();