Show Accurate View Count of StackExchange question

Show accurate view count of StackExchange question

目前為 2024-02-24 提交的版本,檢視 最新版本

// ==UserScript==
// @name         Show Accurate View Count of StackExchange question
// @namespace    http://tampermonkey.net/
// @version      0.1
// @license      MIT
// @description  Show accurate view count of StackExchange question
// @author       aspen138
// @match      *://*.stackexchange.com/*
// @match          *://*.stackoverflow.com/questions/*
// @match          *://superuser.com/questions/*
// @match          *://meta.superuser.com/questions/*
// @match          *://serverfault.com/questions/*
// @match          *://meta.serverfault.com/questions/*
// @match          *://askubuntu.com/questions/*
// @match          *://meta.askubuntu.com/questions/*
// @match          *://mathoverflow.net/questions/*
// @match          *://meta.mathoverflow.net/questions/*
// @match          *://*.stackexchange.com/questions/*
// @match          *://answers.onstartups.com/questions/*
// @match          *://meta.answers.onstartups.com/questions/*
// @match          *://stackapps.com/questions/*
// @match          *://*.stackoverflow.com/review/*
// @match          *://superuser.com/review/*
// @match          *://meta.superuser.com/review/*
// @match          *://serverfault.com/review/*
// @match          *://meta.serverfault.com/review/*
// @match          *://askubuntu.com/review/*
// @match          *://meta.askubuntu.com/review/*
// @match          *://mathoverflow.net/review/*
// @match          *://meta.mathoverflow.net/review/*
// @match          *://*.stackexchange.com/review/*
// @match          *://answers.onstartups.com/review/*
// @match          *://meta.answers.onstartups.com/review/*
// @match          *://stackapps.com/review/*
// @match          *://*.stackoverflow.com/search*
// @match          *://superuser.com/search*
// @match          *://meta.superuser.com/search*
// @match          *://serverfault.com/search*
// @match          *://meta.serverfault.com/search*
// @match          *://askubuntu.com/search*
// @match          *://meta.askubuntu.com/search*
// @match          *://mathoverflow.net/search*
// @match          *://meta.mathoverflow.net/search*
// @match          *://*.stackexchange.com/search*
// @match          *://answers.onstartups.com/search*
// @match          *://meta.answers.onstartups.com/search*
// @match          *://stackapps.com/search*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

//    // Define a function to format the date
//     function formatDate(date) {
//         return date.toISOString().replace('T', ' ').replace(/\..*$/, 'Z');
//     }

//     // Update Asked time
//     const askedTimeElement = document.querySelector('div[title*="Asked"] time');
//     if (askedTimeElement) {
//         const askedDate = new Date(askedTimeElement.getAttribute('datetime'));
//         askedTimeElement.innerText = formatDate(askedDate);
//     }

//     // Update Modified time
//     const modifiedTimeElement = document.querySelector('div[title*="Modified"] a');
//     if (modifiedTimeElement) {
//         const modifiedDate = new Date(modifiedTimeElement.getAttribute('title'));
//         modifiedTimeElement.innerText = formatDate(modifiedDate);
//     }

    // Update Viewed count
    const viewedElement = document.querySelector('div[title*="Viewed"]');
    if (viewedElement) {
        const viewCount = viewedElement.getAttribute('title').match(/Viewed ([\d,]+) times/);
        if (viewCount && viewCount[1]) {
            viewedElement.innerText ='Viewed '+ viewCount[1].replace(',', '') + ' times';
        }
    }
})();

QingJ © 2025

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