PornOne Upload Date

Adds the EXACT upload date for videos. Not just the useless "XX days/months ago".

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         PornOne Upload Date
// @namespace    http://tampermonkey.net/
// @version      1.5
// @description  Adds the EXACT upload date for videos. Not just the useless "XX days/months ago".
// @author       nereids
// @match        https://pornone.com/*
// @grant        none
// @icon         https://icons.duckduckgo.com/ip3/pornone.com.ico
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    // Function to extract uploadDate from JSON-LD script
    function getUploadDateFromJSON() {
        const scripts = document.querySelectorAll('script[type="application/ld+json"]');
        for (let script of scripts) {
            try {
                const data = JSON.parse(script.textContent.trim());
                if (data['@type'] === 'VideoObject' && data.uploadDate) {
                    return data.uploadDate;
                }
            } catch (e) {
                console.log('Failed to parse JSON-LD script:', e);
            }
        }
        return null;
    }

    // Function to add the date
    function addUploadDate() {
        const uploadDateStr = getUploadDateFromJSON();
        if (!uploadDateStr) {
            console.log('Upload date not found in JSON-LD');
            return;
        }

        // Parse the ISO date string
        const uploadDate = new Date(uploadDateStr);
        if (isNaN(uploadDate.getTime())) {
            console.log('Invalid upload date format:', uploadDateStr);
            return;
        }

        // Format as YYYY-MM-DD
        const formattedDate = uploadDate.toISOString().split('T')[0];

        // Find the exact span with the views text
        const targetElement = document.querySelector('span.text-left.mx-4.md\\:ml-0.md\\:my-2.font-medium.md\\:text-f15.text-warm-grey');
        if (!targetElement) {
            console.log('Views span element not found');
            return;
        }

        // Avoid adding multiple times
        if (targetElement.querySelector('.pornone-upload-date')) {
            return;
        }

        // Create the date span
        const dateSpan = document.createElement('span');
        dateSpan.className = 'pornone-upload-date';
        dateSpan.textContent = ` = ${formattedDate}`;

        // Match the exact Tailwind-style color
        dateSpan.style.setProperty('--tw-text-opacity', '1');
        dateSpan.style.color = 'rgba(136,136,136,var(--tw-text-opacity))';
        dateSpan.style.display = 'inline';

        // Append directly to the span
        targetElement.appendChild(dateSpan);

        console.log('Upload date added:', formattedDate);
    }

    // Run on load
    function runOnLoad() {
        if (document.readyState === 'loading') {
            document.addEventListener('DOMContentLoaded', addUploadDate);
        } else {
            addUploadDate();
        }
    }

    runOnLoad();

    // Observe for dynamic content changes (in case the element loads later)
    const observer = new MutationObserver(function(mutations) {
        let shouldRun = false;
        mutations.forEach(mutation => {
            if (mutation.addedNodes.length > 0) {
                shouldRun = true;
            }
        });
        if (shouldRun) {
            setTimeout(addUploadDate, 500);
        }
    });

    if (document.body) {
        observer.observe(document.body, { childList: true, subtree: true });
    }
})();