SLR Not Interested

Thumb down for videos SLR https://forum.sexlikereal.com/d/6856-mark-videos-as-not-interested

目前為 2024-03-04 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         SLR Not Interested
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Thumb down for videos SLR https://forum.sexlikereal.com/d/6856-mark-videos-as-not-interested
// @author       jambavant
// @match        https://www.sexlikereal.com/*
// @license      MIT
// @grant        GM_xmlhttpRequest
// ==/UserScript==

(function() {
    'use strict';

    let isHidden = localStorage.videosHidden === 'true';

    // Function to toggle visibility
    function toggleVisibility() {
        isHidden = !isHidden
        localStorage.videosHidden = isHidden;
        toggleButton.textContent = isHidden ? 'Show all videos' : 'Hide discarded videos';
        document.querySelectorAll('button.hidable-icon').forEach(btn => {
            btn.closest("article").style.display = isHidden ? 'none' : '';
        });
    }
    // Create and style toggle button
    const toggleButton = document.createElement('button');
    toggleButton.textContent = isHidden ? 'Show all videos' : 'Hide discarded videos';
    Object.assign(toggleButton.style, {position: 'fixed', top: '10px', left: '50%', transform: 'translateX(-50%)', zIndex: '1000', padding: '10px 20px'});
    toggleButton.addEventListener('click', toggleVisibility);
    document.body.appendChild(toggleButton);

    const iconChecked = `<i class="material-icons" style="color: red; font-size: 20px;">thumb_down</i>`
    const iconUnchecked = `<i class="material-icons-outlined" style="color: grey; font-size: 20px;">thumb_down</i>`

    function toggleNotInterested(ptr) {
        const btn = ptr.target.parentElement
        const data = new URLSearchParams({
            "scene_id":    btn.sceneId,
            "project_id":  globalObj.projectId,
            "playlist_id": globalObj.notInterestedPlaylistId,
            "csrf_token":  globalObj.csrf_token
        }).toString();
        console.log(data)
        if (btn.classList.contains("is-checked")) {
            GM_xmlhttpRequest({
                method: "POST",
                url: "/ajax_playlists/removescene",
                data: data,
                headers: {"Content-Type": "application/x-www-form-urlencoded"},
                onload: function(response) {
                    console.log(response)
                    if (JSON.parse(response.responseText).status == 2) {
                        btn.innerHTML = iconUnchecked
                        btn.classList.toggle("is-checked")
                        ptr.view.window.snackbar("Removed from not-interested")
                    } else {
                        ptr.view.window.snackbar("Something went wrong when removing")

                    }
                }
            })
        } else {
            GM_xmlhttpRequest({
                method: "POST",
                url: "/ajax_playlists/addscene",
                data: data,
                headers: {"Content-Type": "application/x-www-form-urlencoded"},
                onload: function(response) {
                    console.log(response)
                    if (JSON.parse(response.responseText).status == 1) {
                        btn.innerHTML = iconChecked
                        btn.classList.toggle("is-checked")
                        ptr.view.window.snackbar("Added to not-interested")
                    } else {
                        ptr.view.window.snackbar("Something went wrong when adding")
                    }
                }
            })
        }

    }

    document.head.innerHTML += '<link href="https://fonts.googleapis.com/icon?family=Material+Icons|Material+Icons+Outlined" rel="stylesheet" />'

    function fetchPlaylistsAndUpdateVideos() {

        const url = `/ajax_playlists/getList?project_id=${globalObj.projectId}&user_id=${globalObj.userId}`;
        GM_xmlhttpRequest({
            method: "GET",
            url: url,
            onload: function(response) {
                const playlists = JSON.parse(response.responseText);
                playlists.list.forEach(playlist => {
                    if (playlist.title == "not-interested") {
                        globalObj.notInterestedPlaylistId = playlist._id
                        document.querySelectorAll('article').forEach(article => {
                            const sceneId = Number(article.getAttribute('data-scene-id'))
                            const watchLaterButton = article.querySelector('.c-playlist-watch-later-trigger--btn');
                            const btn = document.createElement('button');
                            btn.sceneId = sceneId
                            btn.classList = ["o-btn--text"]
                            btn.addEventListener('click', toggleNotInterested);
                            watchLaterButton.parentElement.appendChild(btn)
                            if (playlist.scenes.includes(sceneId)) {
                                btn.classList.toggle("is-checked")
                                btn.innerHTML = iconChecked
                                article.style.display = isHidden ? 'none' : '';
                            } else {
                                btn.innerHTML = iconUnchecked
                            }
                        })
                    }
                })
            },
            onerror: function(error) {
                console.error('Error fetching playlists:', error);
            }
        });
    }

    fetchPlaylistsAndUpdateVideos();



})();