Greasy Fork is available in English.

Prolific Sidebar Toggle

Toggle the sidebar visibility

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

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

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği indirebilmeniz için ayrıca Tampermonkey gibi bir eklenti kurmanız gerekmektedir.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name         Prolific Sidebar Toggle
// @version      1.1
// @description  Toggle the sidebar visibility
// @author       Lintilla
// @match        https://app.prolific.com/studies
// @grant        none
// @run-at       document-idle
// @license      MIT
// @namespace http://tampermonkey.net/
// ==/UserScript==

(function() {
    'use strict';

    const STORAGE_KEY = 'sidebar-hidden';

    function setSidebarState(hidden) {
        const sidebar = document.querySelector('.projects-sidebar');
        if (!sidebar) return;
        sidebar.style.display = hidden ? 'none' : 'block';
        localStorage.setItem(STORAGE_KEY, hidden ? '1' : '0');
    }

    function getSidebarState() {
        return localStorage.getItem(STORAGE_KEY) === '1';
    }

    function applySidebarState() {
        const sidebar = document.querySelector('.projects-sidebar');
        if (!sidebar) return;
        sidebar.style.display = getSidebarState() ? 'none' : 'block';
    }

    function addSidebarToggle() {
        const messagesLink = document.querySelector('a[data-testid="messages-link"]');
        if (!messagesLink) return;
        if (document.getElementById('sidebar-toggle-link')) return;

        const toggleLink = document.createElement('a');
        toggleLink.href = "#";
        toggleLink.id = "sidebar-toggle-link";
        toggleLink.className = "nav-link";

        function updateToggleText() {
            toggleLink.textContent = getSidebarState() ? "Show Sidebar" : "Hide Sidebar";
        }

        toggleLink.addEventListener('click', function(e) {
            e.preventDefault();
            const hidden = !getSidebarState();
            setSidebarState(hidden);
            updateToggleText();
            applySidebarState();
        });

        applySidebarState();
        updateToggleText();

        messagesLink.parentNode.insertBefore(toggleLink, messagesLink.nextSibling);
    }

    addSidebarToggle();
    const observer = new MutationObserver(() => {
        addSidebarToggle();
        applySidebarState();
    });
    observer.observe(document.body, { childList: true, subtree: true });
})();