AnySex Upload Date

Displays the video upload date

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         AnySex Upload Date
// @namespace    AnySexUploadDate@nereids
// @version      1.1.0
// @description  Displays the video upload date
// @author       nereids
// @license      MIT
// @icon         https://icons.duckduckgo.com/ip3/anysex.com.ico
// @match        https://anysex.com/*
// @grant        none
// @run-at       document-end
// ==/UserScript==

(function () {
    'use strict';

    const poll = setInterval(() => {
        const pageTitle = document.querySelector('.page-title');
        const jsonScript = Array.from(document.querySelectorAll('script[type="application/ld+json"]'))
            .find(s => s.textContent.includes('"uploadDate"'));

        if (pageTitle && jsonScript) {
            clearInterval(poll);
            insertUploadDateBadge(pageTitle, jsonScript);
        }
    }, 250);

    function insertUploadDateBadge(container, scriptEl) {
        let data;
        try {
            data = JSON.parse(scriptEl.textContent);
        } catch (e) {
            console.error('AnySex uploadDate: JSON parse error');
            return;
        }

        const isoDate = data.uploadDate || data.datePublished;
        if (!isoDate) return;

        const date = new Date(isoDate);
        if (isNaN(date)) return;

        // Format: 22 Mar 2013  OR  Mar 2013  if you prefer shorter
        const formatted = date.toLocaleDateString('en-GB', {
            day: 'numeric',
            month: 'short',
            year: 'numeric'
        }).replace(/,/g, '');

        const durationBadge = container.querySelector('.badge.duration');
        if (!durationBadge) return;

        const badge = document.createElement('span');
        badge.className = 'badge';
        badge.textContent = formatted;
        badge.title = 'Upload date';
        badge.style.marginLeft = '5px'; // slight extra spacing after duration

        durationBadge.after(badge);
    }
})();