提示文章时间

添加文章时间。支持csdn,掘金,思否,博客园,stackoverflow,知乎专栏,简书。有问题发邮件:[email protected]

目前为 2021-12-14 提交的版本。查看 最新版本

// ==UserScript==
// @name        提示文章时间 
// @namespace   xky1000.cn
// @match       https://blog.csdn.net/*
// @match       https://juejin.cn/*
// @match       https://segmentfault.com/*
// @match       https://www.jianshu.com/p/*
// @match       https://www.cnblogs.com/*/p/*
// @match       https://stackoverflow.com/questions/*
// @match       https://zhuanlan.zhihu.com/p/*
// @version     0.1.1
// @author      xky
// @grant       GM_addStyle
// @license     MIT
// @description 添加文章时间。支持csdn,掘金,思否,博客园,stackoverflow,知乎专栏,简书。有问题发邮件:[email protected]
// ==/UserScript==


GM_addStyle(`#show_timer {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 10000;
    background-color: #ff9999;
    padding: 0 13px 0 10px;
    font-size: 10px
}`)

function show(text) {
    const date = new Date(text);
    const year = date.getFullYear();
    const month = date.getMonth() + 1;
    const day = date.getDate();
    const div = document.createElement('div')
    div.id = 'show_timer'
    div.innerText = `${year}/${month}/${day}`
    document.body.appendChild(div);
}

function route(url) {
    if (document.URL.indexOf(url) !== -1) {
        return true;
    }
}


try {
    if (route('https://blog.csdn.net')) {
        show(document.querySelector('.time').innerText);
    } else if (route('https://juejin.cn')) {
        setTimeout(() => show(document.querySelector('.meta-box .time').dateTime), 500)
    } else if (route('https://segmentfault.com')) {
        show(document.querySelector('time').dateTime);
    } else if (route('https://www.jianshu.com')) {
        setTimeout(() => show(document.querySelector('time').dateTime), 500)
    } else if (route('https://www.cnblogs.com')) {
        show(document.querySelector('#post-date').innerText);
    } else if (route('https://stackoverflow.com')) {
        show(document.querySelector('.relativetime').title);
    } else if (route('https://zhuanlan.zhihu.com')) {
        show(document.querySelector('.ContentItem-time').innerText.slice(4));
    }
} catch (e) {
    console.log(e)
}

QingJ © 2025

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