Greasy Fork

Greasy Fork is available in English.

提示文章时间

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

当前为 2021-12-13 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==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.0
// @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) {
    let date = new Date(text);
    let year = date.getFullYear();
    let month = date.getMonth() + 1;
    let day = date.getDate();
    let 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')) {
        show(document.querySelector('time').dateTime);
    } 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)
}