您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
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". Also checks if users are friends and adds a label accordingly.
当前为
// ==UserScript== // @name Camwhores.tv user preview inside messages // @namespace https://sleazyfork.org/users/1281730-vipprograms // @version 0.5 // @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". Also checks if users are friends and adds a label accordingly. // @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'; // Check if on the messages page if (window.location.href == "https://www.camwhores.tv/my/messages/") { var unreadNotifications = document.querySelectorAll('.unread-notification'); unreadNotifications.forEach(function(notification) { // Apply styles to move the element to top-left corner notification.style.top = "0"; notification.style.left = "0"; }); // Get all img elements with class thumb lazy-load var thumbnails = document.querySelectorAll('img.thumb.lazy-load'); thumbnails.forEach(function(thumbnail) { // Get the title attribute of the thumbnail var usernameText = thumbnail.getAttribute('title'); // console.log("Username:", usernameText); // Check if usernameText is not null or empty if (usernameText) { // Find the username link and extract the user ID from its href attribute var usernameLink = document.querySelector('a[title="' + usernameText + '"]'); if (usernameLink) { var href = usernameLink.getAttribute('href'); var userIdMatch = href.match(/\/(\d+)\/$/); if (userIdMatch && userIdMatch.length > 1) { var userId = userIdMatch[1]; var usernameUrl = "https://www.camwhores.tv/members/" + userId + "/"; // console.log("Username URL:", usernameUrl); // Fetch page to check friendship GM_xmlhttpRequest({ method: "GET", url: usernameUrl, onload: function(response) { // console.log("Response:", response); var parser = new DOMParser(); var htmlDoc = parser.parseFromString(response.responseText, "text/html"); // Check if friendship button has "done" class var friendshipButton = htmlDoc.querySelector('a[data-action="add_to_friends"].button.done'); if (friendshipButton) { // console.log("Friendship button found:", friendshipButton); // Add label "Friends" next to the username var imgElement = document.querySelector('img[title="' + usernameText + '"]'); if (imgElement) { // console.log("Image element found:", imgElement); var divElement = document.createElement('div'); divElement.textContent = "Friends ✅"; divElement.style.position = "absolute"; divElement.style.top = "0"; divElement.style.right = "0"; divElement.style.backgroundColor = "black"; divElement.style.color = "white"; divElement.style.paddingLeft = ".33rem"; divElement.style.paddingRight = ".25rem"; divElement.style.paddingTop = ".25rem"; divElement.style.paddingBottom = ".25rem"; // console.log("Div element created:", divElement); imgElement.parentNode.insertBefore(divElement, imgElement); // console.log("Label 'Friends' added next to the username."); } } } }); } else { console.log("User ID not found in href for:", usernameText); } } else { console.log("Username link not found for:", usernameText); } } }); }else{ // 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 = "<div id=gen_joined_text>Joined " + joinedDateText + "<br>" + extractedTitle[1] + " videos, last " + contentText + "</div>"; // 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 += "<div id=gen_joined_text>Joined " + joinedDateText + "<br>" + "<b>No videos</b></div>"; } } } }); } // 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.'); setTimeout(function() { var gen_joined_text = document.getElementById('gen_joined_text'); gen_joined_text.innerHTML = "<br>" + gen_joined_text.innerHTML; // gen_joined_text.style.marginTop = "1em"; // gen_joined_text.classList.add("custom-margin-top"); }, 200); // Adjust the delay time as needed } } })();