SLR Not Interested

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

当前为 2024-03-04 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 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();



})();