知乎回答头部显示回答日期

try to take over the world!

目前為 2020-04-07 提交的版本,檢視 最新版本

// ==UserScript==
// @name         知乎回答头部显示回答日期
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  try to take over the world!
// @author       You
// @include      *.zhihu.com/*
// @grant        none
// @require      https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js
// ==/UserScript==

function timestampToTime(timestamp) {
    var date = new Date(timestamp);
    var Y = date.getFullYear() + '-';
    var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
    var D = date.getDate() + ' ';
    var h = date.getHours() + ':';
    var m = date.getMinutes() + ':';
    var s = date.getSeconds();
    return Y + M + D + h + m + s;
}
(function () {
    setInterval(() => {
        $('.yupeg_add_time').remove();
        $('.ContentItem ').each(function (index, element) {
            let ctime = $(this).find('meta[itemprop="dateCreated"]'),
                mtime = $(this).find('meta[itemprop="dateModified"]'),
                cc = ctime.attr('content'),
                mc = mtime.attr('content'),
                cd = timestampToTime((new Date(cc)).getTime()),
                md = timestampToTime((new Date(mc)).getTime());
            let add = $(this).find('div[class="css-h5al4j"]');
            add.append(`<span class='yupeg_add_time'>&nbsp;&nbsp;&nbsp;&nbsp;创建于:${cd}&nbsp;&nbsp;&nbsp;&nbsp;最后修改:${md}</span>`);
        });
    }, 1000);
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址