您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Deobfuscate the "n days ago" dates on Hacker News with YYYY-MM-DD tooltips
当前为
// ==UserScript== // @name Hacker News Date Tooltips // @description Deobfuscate the "n days ago" dates on Hacker News with YYYY-MM-DD tooltips // @author chocolateboy // @copyright chocolateboy // @namespace https://github.com/chocolateboy/userscripts // @version 1.0.0 // @license GPL: http://www.gnu.org/copyleft/gpl.html // @include https://news.ycombinator.com/* // @require https://code.jquery.com/jquery-3.3.1.min.js // @require https://unpkg.com/[email protected]/dist/dayjs.min.js // @grant GM_log // ==/UserScript== // XXX note: the unused grant is a workaround for a Greasemonkey bug: // https://github.com/greasemonkey/greasemonkey/issues/1614 const DELTA = 1, UNIT = 2 const DATES = $('html').attr('op') === 'user' ? 'table:eq(-1) tr:eq(1) td:eq(-1)' : 'span.age a' function isoDate (ago) { const match = ago.match(/^(\d+)\s+(\w+)\s+ago$/) let date if (match) { date = dayjs().subtract(match[DELTA], match[UNIT]).format('YYYY-MM-DD') } return date } $(DATES).each(function () { const $this = $(this) const ago = $.trim($this.text()) const date = isoDate(ago) if (date) { $this.attr('title', date) } })