SLR Hide video shortcut

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name         SLR Hide video shortcut
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  Thumb down to hide videos in 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';

    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
        if (btn.classList.contains("is-checked")) {
            GM_xmlhttpRequest({
                method: "POST",
                url: "/ajax/manageuserpreference",
                data: new URLSearchParams({"project": globalObj.projectId, "_id": btn.sceneId, "type": 1,
                                          "action": "remove", "csrf_token": globalObj.csrf_token}).toString(),
                headers: {"Content-Type": "application/x-www-form-urlencoded"},
                onload: function(response) {
                    if (JSON.parse(response.responseText).status) {
                        btn.innerHTML = iconUnchecked
                        btn.classList.toggle("is-checked")
                    } else {
                        ptr.view.window.snackbar("Something went wrong when removing")

                    }
                }
            })
        } else {
            GM_xmlhttpRequest({
                method: "POST",
                url: "/ajax/manageuserpreference",
                data: new URLSearchParams({"project": globalObj.projectId, "_id": btn.sceneId, "type": 1,
                                          "action": "add", "csrf_token": globalObj.csrf_token}).toString(),
                headers: {"Content-Type": "application/x-www-form-urlencoded"},
                onload: function(response) {
                    if (JSON.parse(response.responseText).status) {
                        btn.innerHTML = iconChecked
                        btn.classList.toggle("is-checked")
                    } 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() {

        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)
            btn.innerHTML = iconUnchecked
        })
    }

    fetchPlaylistsAndUpdateVideos();



})();