☰

SC VR Thumbnail Filter

Filter main and tag pages on Stripchat to show only VR thumbnails.

Voor het installeren van scripts heb je een extensie nodig, zoals Tampermonkey, Greasemonkey of Violentmonkey.

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

Voor het installeren van scripts heb je een extensie nodig, zoals Tampermonkey of Violentmonkey.

Voor het installeren van scripts heb je een extensie nodig, zoals Tampermonkey of Userscripts.

Voor het installeren van scripts heb je een extensie nodig, zoals {tampermonkey_link:Tampermonkey}.

Voor het installeren van scripts heb je een gebruikersscriptbeheerder nodig.

(Ik heb al een user script manager, laat me het downloaden!)

Voor het installeren van gebruikersstijlen heb je een extensie nodig, zoals {stylus_link:Stylus}.

Voor het installeren van gebruikersstijlen heb je een extensie nodig, zoals {stylus_link:Stylus}.

Voor het installeren van gebruikersstijlen heb je een extensie nodig, zoals {stylus_link:Stylus}.

Voor het installeren van gebruikersstijlen heb je een gebruikersstijlbeheerder nodig.

Voor het installeren van gebruikersstijlen heb je een gebruikersstijlbeheerder nodig.

Voor het installeren van gebruikersstijlen heb je een gebruikersstijlbeheerder nodig.

(Ik heb al een beheerder - laat me doorgaan met de installatie!)

// ==UserScript==
// @name         SC VR Thumbnail Filter
// @namespace    http://tampermonkey.net/
// @version      2026-12-05
// @description  Filter main and tag pages on Stripchat to show only VR thumbnails.
// @author       Nima Devil
// @license      MIT
// @match        https://stripchat.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=stripchat.com
// @run-at       document-start
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    const STYLE_ID = "sc-vr-filter-style";
    const CONTROL_ID = "sc-vr-filter-control";
    const STORAGE_KEY = "sc-vr-filter-only";
    const STYLE_CSS = `:is([data-testid="model-list-item"], [data-model-list-root="item"]):not(:has([class*="ModelListItemBadge__vr"], [title="Virtual Reality"])) { display: none !important; }`;

    const LISTING_ROOT_SEGMENTS = new Set([
        "girls",
        "couples",
        "men",
        "trans",
        "tags",
        "tag",
        "categories",
        "category",
        "cams",
        "recommended",
        "best",
        "top",
        "new",
        "vr",
        "hd",
        "mobile",
        "favorites",
        "following",
        "history",
        "search",
        "female",
        "male"
    ]);

    let vrOnly = readVrOnlyState();

    function readVrOnlyState() {
        try {
            return window.localStorage.getItem(STORAGE_KEY) === "1";
        } catch (_err) {
            return false;
        }
    }

    function saveVrOnlyState(enabled) {
        try {
            window.localStorage.setItem(STORAGE_KEY, enabled ? "1" : "0");
        } catch (_err) {
            // Ignore storage errors under strict privacy settings
        }
    }

    function setVrOnly(enabled) {
        vrOnly = Boolean(enabled);
        saveVrOnlyState(vrOnly);
        syncPageState();
    }

    function isMainOrTagPage() {
        const pathname = window.location.pathname || "/";
        const segments = pathname.split("/").filter(Boolean);
        if (segments.length === 0) {
            return true;
        }
        return LISTING_ROOT_SEGMENTS.has(segments[0].toLowerCase());
    }

    function syncStyle() {
        const existingStyle = document.getElementById(STYLE_ID);

        if (isMainOrTagPage() && vrOnly) {
            const target = document.head || document.documentElement;
            if (!target) {
                return;
            }

            if (existingStyle) {
                if (document.head && existingStyle.parentNode !== document.head) {
                    document.head.appendChild(existingStyle);
                }
                return;
            }

            const style = document.createElement("style");
            style.id = STYLE_ID;
            style.textContent = STYLE_CSS;
            target.appendChild(style);
        } else if (existingStyle) {
            existingStyle.remove();
        }
    }

    function createRadioOption(labelText, value, checked) {
        const label = document.createElement("label");
        label.style.cssText = "display: inline-flex; align-items: center; gap: 5px; cursor: pointer; margin: 0;";

        const input = document.createElement("input");
        input.type = "radio";
        input.name = "sc-vr-filter-mode";
        input.value = value;
        input.checked = checked;
        input.style.cssText = "margin: 0; cursor: pointer;";
        input.addEventListener("change", function() {
            if (input.checked) {
                setVrOnly(value === "vr");
            }
        });

        const text = document.createElement("span");
        text.textContent = labelText;

        label.appendChild(input);
        label.appendChild(text);
        return label;
    }

    function syncControlUi() {
        const existing = document.getElementById(CONTROL_ID);

        if (!isMainOrTagPage()) {
            if (existing) {
                existing.remove();
            }
            return;
        }

        if (!document.body) {
            return;
        }

        if (existing) {
            const allInput = existing.querySelector('input[value="all"]');
            const vrInput = existing.querySelector('input[value="vr"]');
            if (allInput) {
                allInput.checked = !vrOnly;
            }
            if (vrInput) {
                vrInput.checked = vrOnly;
            }
            return;
        }

        const container = document.createElement("div");
        container.id = CONTROL_ID;
        container.style.cssText = "position: fixed; bottom: 16px; right: 16px; z-index: 2147483647; display: inline-flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 999px; background: rgba(20, 20, 24, 0.9); color: #f5f5f5; border: 1px solid rgba(255, 255, 255, 0.16); box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45); font-family: system-ui, -apple-system, sans-serif; font-size: 13px; line-height: 1; user-select: none;";

        container.appendChild(createRadioOption("All", "all", !vrOnly));
        container.appendChild(createRadioOption("VR Only", "vr", vrOnly));

        document.body.appendChild(container);
    }

    function syncPageState() {
        syncStyle();
        syncControlUi();
    }

    function wrapHistoryMethod(methodName) {
        if (typeof History === "undefined" || !History.prototype || typeof History.prototype[methodName] !== "function") {
            return;
        }
        const original = History.prototype[methodName];
        History.prototype[methodName] = function() {
            const result = original.apply(this, arguments);
            syncPageState();
            return result;
        };
    }

    wrapHistoryMethod("pushState");
    wrapHistoryMethod("replaceState");
    window.addEventListener("popstate", syncPageState);
    window.addEventListener("hashchange", syncPageState);

    if (window.navigation && typeof window.navigation.addEventListener === "function") {
        window.navigation.addEventListener("currententrychange", syncPageState);
    }

    if (document.readyState === "loading") {
        document.addEventListener("DOMContentLoaded", syncPageState, { once: true });
    }

    syncPageState();
})();