XVideos Upload Date

Displays the upload date 'cause that's a pretty basic thing that a video website should have.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name         XVideos Upload Date
// @namespace    http://tampermonkey.net/
// @version      1.3
// @description  Displays the upload date 'cause that's a pretty basic thing that a video website should have.
// @author       nereids
// @match        https://www.xvideos.com/video*
// @grant        none
// @license      MIT
// @author       nereids
// @icon         https://icons.duckduckgo.com/ip3/xvideos.com.ico
// ==/UserScript==

(function() {
    'use strict';

    // Function to extract uploadDate from JSON-LD
    function getUploadDate() {
        const scripts = document.querySelectorAll('script[type="application/ld+json"]');
        for (const script of scripts) {
            try {
                const json = JSON.parse(script.textContent);
                if (json.uploadDate) {
                    // Format the date to a readable string, e.g., "October 9, 2025"
                    return new Date(json.uploadDate).toLocaleDateString('en-US', {
                        year: 'numeric',
                        month: 'long',
                        day: 'numeric'
                    });
                }
            } catch (e) {
                console.error('Error parsing JSON-LD:', e);
            }
        }
        return 'Unknown';
    }

    // Get the upload date
    const uploadDate = getUploadDate();

    // Find the duration element: <span class="duration">1 h 31 min</span>
    const durationElement = document.querySelector('span.duration');

    if (durationElement) {
        // Create a new span element for the upload date
        const dateSpan = document.createElement('span');
        dateSpan.textContent = `${uploadDate}`;
        dateSpan.className = 'duration'; // Reuse the same class for identical styling

        // Apply inline styles to ensure consistency (in case class is overridden)
        const style = {
            display: 'inline-block',
            fontSize: '15px',
            lineHeight: '22px',
            height: '22px',
            padding: '0 6px',
            background: '#de2600',
            borderRadius: '3px',
            color: '#FFFFFF',
            fontWeight: '700',
            margin: '5px 0 0 4px',
            verticalAlign: 'top'
        };

        Object.assign(dateSpan.style, style);

        // Insert the date span right after the duration element
        durationElement.parentNode.insertBefore(dateSpan, durationElement.nextSibling);
    } else {
        console.warn('Duration element not found. Selector may need adjustment.');
    }
})();