Thumb down for videos SLR https://forum.sexlikereal.com/d/6856-mark-videos-as-not-interested
当前为
// ==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();
})();