Artificial Intelligence
Please fill the required field.

Generate a userscript for Greasemonkey that will hide videos from specified channel on xvideos.com and hide watched videos. What information do you need to make it work? Here is the example script, that hides videos base on keyword, maybe you can be in


To modify the provided userscript for Greasemonkey to hide videos from specified channels and those that have been watched on xvideos.com, you'll need to add functionality for detecting and filtering this content. 1. **Specify Channels**: You'll need a way to define the channels you want to hide. 2. **Tracking Watched Videos**: You could use `localStorage` to remember video IDs that have been watched, although keep in mind this method will only allow tracking on the same device and browser. 3. **Filtering Logic**: The logic to hide videos that match the specified channels and those that have been watched. Below is an example of how you might structure your Greasemonkey userscript to accomplish this: ```javascript // ==UserScript== // @name XVideos Filtered View // @namespace http://tampermonkey.net/ // @version 1.0 // @license MIT // @description Hides videos from specified channels and watched videos on xvideos.com. // @author YourName // @match https://*.xvideos.com/* // @exclude https://*.xvideos.com/embedframe/* // @grant none // ==/UserScript== (function() { 'use strict'; // Define the channels to hide const channelsToHide = ['ChannelName1', 'ChannelName2']; // Add your channel names here const watchedVideos = JSON.parse(localStorage.getItem('watchedVideos')) || []; // Function to check if a video is watched or from a specified channel function shouldHideVideo(video) { const uploader = video.querySelector('[class*=name]')?.innerText; const videoId = video.getAttribute('data-id'); // Check if video is from a channel to hide if (channelsToHide.includes(uploader)) { return true; } // Check if video is in watched list if (watchedVideos.includes(videoId)) { return true; } return false; } // Hide videos based on rules function hideVideos() { const videos = document.querySelectorAll('div.thumb-block[id^=video_]:not(.thumb-ad)'); videos.forEach(video => { if (shouldHideVideo(video)) { video.style.display = 'none'; } }); } // Watch for changes in the video list (like infinite scroll) const observer = new MutationObserver(hideVideos); observer.observe(document.getElementById('content'), { childList: true, subtree: true }); // Initial call to hide videos hideVideos(); // Example of marking a video as watched // You could call this function whenever a video is watched const markAsWatched = (videoId) => { if (!watchedVideos.includes(videoId)) { watchedVideos.push(videoId); localStorage.setItem('watchedVideos', JSON.stringify(watchedVideos)); } }; // Sample usage with a simulated watching event (replace with actual logic) // Example: markAsWatched('12345'); // Use actual video id when a video is watched })(); ``` ### Instructions: 1. **Edit the `channelsToHide` Array**: Fill this array with the channel names (or parts of the names) you want to filter out. 2. **Mark Videos as Watched**: Use the `markAsWatched` function wherever you implement video watching logic to keep track of watched videos. 3. **Install and Use**: Copy this script into your Greasemonkey or Tampermonkey dashboard and enable it. It will start hiding videos based on the specified criteria. ### Notes: - Make sure to test thoroughly as this script relies on the specific structure of the xvideos website, which may change over time. - The watched videos functionality is simplistic; for a more robust implementation, consider adding features to mark videos when a user indicates they have finished watching them.