AnySex Upload Date

Displays the video upload date

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 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);
    }
})();