Camwhores.tv user preview inside messages

Extracts the URL from the first message on camwhores.tv/my/messages/*, retrieves the title from the linked page, gets the content from the video element, and adds the generated text to the visible page. If successful, adds the generated text to the visible page, otherwise adds "No videos".

31.03.2024 itibariyledir. En son verisyonu görün.

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

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

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

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

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

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.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name         Camwhores.tv user preview inside messages
// @namespace    https://sleazyfork.org/users/1281730-vipprograms
// @version      0.3
// @description  Extracts the URL from the first message on camwhores.tv/my/messages/*, retrieves the title from the linked page, gets the content from the video element, and adds the generated text to the visible page. If successful, adds the generated text to the visible page, otherwise adds "No videos".
// @author       vipprograms
// @match        https://www.camwhores.tv/my/messages/*
// @grant        GM_xmlhttpRequest
// @icon         data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAgMAAABinRfyAAAAIGNIUk0AAHomAACAhAAA+gAAAIDoAAB1MAAA6mAAADqYAAAXcJy6UTwAAAAMUExURQAAAP8ANwwA/////7gbQJkAAAABdFJOUwBA5thmAAAAAWJLR0QDEQxM8gAAAAd0SU1FB+gDHhIuCjXV/h8AAAA4SURBVAjXY2ANDQ1gEA0NDWEIYWBgZAhgAAIUghEiC1YHBhpMDRpIhBbXghUMXKtWLWBgWqHVAACjlwz/pN0YPwAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAyNC0wMy0zMFQxODo0NjowOSswMDowME+iXNIAAAAldEVYdGRhdGU6bW9kaWZ5ADIwMjQtMDMtMzBUMTg6NDY6MDkrMDA6MDA+/+RuAAAAKHRFWHRkYXRlOnRpbWVzdGFtcAAyMDI0LTAzLTMwVDE4OjQ2OjEwKzAwOjAwMNiA/AAAAABJRU5ErkJggg==
// ==/UserScript==

(function() {
    'use strict';

    // Function to fetch the URL and extract title, content, and joined date
    function fetchAndExtract(url) {
        GM_xmlhttpRequest({
            method: "GET",
            url: url,
            onload: function(response) {
                // Parse the response text into a HTML document
                var parser = new DOMParser();
                var htmlDoc = parser.parseFromString(response.responseText, "text/html");

                // Get the text of the specified elements
                var titleElement = htmlDoc.evaluate('//*[@id="list_videos_uploaded_videos"]/div[1]/h2', htmlDoc, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null);
                var contentElement = htmlDoc.evaluate('//*[@id="list_videos_uploaded_videos_items"]/div[1]/a/div[3]/div[1]/em', htmlDoc, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null);
                var joinedDateElement = htmlDoc.evaluate('/html/body/div[2]/div[2]/div/div[2]/div[2]/div/div/div[1]/div[3]/em', htmlDoc, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null);
                var joinedDateText = joinedDateElement.singleNodeValue.textContent;

                // Check if the elements exist
                if (titleElement && titleElement.singleNodeValue && contentElement && contentElement.singleNodeValue && joinedDateElement && joinedDateElement.singleNodeValue) {
                    var titleText = titleElement.singleNodeValue.textContent;
                    // Extract text inside parentheses from title
                    var extractedTitle = titleText.match(/\(([^)]+)\)/);
                    if (extractedTitle && extractedTitle.length > 1) {
                        var contentText = contentElement.singleNodeValue.textContent;
                        var generatedText = "Joined " + joinedDateText + "<br>" + extractedTitle[1] + " videos, last " + contentText;
                        // Add generated text to the visible page
                        var messageDiv = document.evaluate('//*[@id="list_messages_my_conversation_messages_items"]/div/div[3]', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null);
                        if (messageDiv && messageDiv.singleNodeValue) {
                            messageDiv.singleNodeValue.innerHTML += generatedText;
                        }
                    } else {
                        console.log('Text inside parentheses in title not found.');
                    }
                } else {
                    console.log('Title, content, or joined date element not found. Probably no videos uploaded yet.');
                    // Add "No videos" to the visible page
                    var messageDiv = document.evaluate('//*[@id="list_messages_my_conversation_messages_items"]/div/div[3]', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null);
                    if (messageDiv && messageDiv.singleNodeValue) {
                        messageDiv.singleNodeValue.innerHTML += "Joined " + joinedDateText + "<br>" + "<b>No videos</b>";
                    }
                }
            }
        });
    }

    // Get the href attribute of the first message
    var messageLink = document.evaluate('//*[@id="list_messages_my_conversation_messages_items"]/div/div[1]/a', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null);

    // Check if the element exists
    if (messageLink && messageLink.singleNodeValue) {
        // Get the URL from the message link
        var messageUrl = messageLink.singleNodeValue.href;
        // Fetch and extract title, content, and joined date from the URL
        fetchAndExtract(messageUrl);
    } else {
        console.log('Message link not found.');
    }

    // Remove class "bottom" from specified element
    var bottomElement = document.evaluate('//*[@id="list_messages_my_conversation_messages_items"]/div/div[3]/form/div', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null);
    if (bottomElement && bottomElement.singleNodeValue) {
        bottomElement.singleNodeValue.style.marginTop = "1em";
        bottomElement.singleNodeValue.style.marginBottom = "1em";
        bottomElement.singleNodeValue.classList.remove("bottom");
    } else {
        console.log('Bottom element not found.');
    }
})();