pplx Never Suggest - Hide Perplexity Suggestions & Widgets

Hide suggestion dropdown, homepage primers, and widgets on Perplexity

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

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

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

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

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

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

(I already have a user script manager, let me install it!)

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.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         pplx Never Suggest - Hide Perplexity Suggestions & Widgets
// @namespace    https://github.com/ckep1/pplx-never-suggest
// @version      1.1.0
// @description  Hide suggestion dropdown, homepage primers, and widgets on Perplexity
// @author       Chris Kephart
// @match        https://www.perplexity.ai/*
// @grant        GM_setValue
// @grant        GM_getValue
// @grant        GM_registerMenuCommand
// @run-at       document-start
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    const defaultSettings = {
        hideSuggestions: true,
        hidePrimers: true,
        hideUpsells: true
    };

    function getSetting(key) {
        return GM_getValue(key, defaultSettings[key]);
    }

    function setSetting(key, value) {
        GM_setValue(key, value);
        location.reload();
    }

    // --- localStorage overrides ---

    const LS_DEFS = {
        suggestions: [
            { key: 'pplx.local-user-settings.isSuggestionsDisabled', value: 'true' }
        ],
        primers: [
            { key: 'pplx.local-user-settings.isHomepageWidgetsDisabled', value: 'true' },
            { key: 'pplx.local-user-settings.isDiscoverInterestBoxDismissed', value: 'true' }
        ],
        upsells: [
            { key: 'pplx.local-user-settings.isEnterpriseAdDismissed', value: 'true' },
            { key: 'pplx.local-user-settings.isSidebarConnectorsAdDismissed', value: 'true' },
            { key: 'pplx.local-user-settings.isSportsIosCtaDismissed', value: 'true' },
            { key: 'pplx.local-user-settings.isStudentSpaceUpsellDismissed', value: 'true' },
            { key: 'always-on-download-comet-banner-enabled', value: 'false' },
            { key: 'pplx_show_comet_upsell_existing_comet_user', value: 'false' }
        ]
    };

    function applySettings() {
        if (getSetting('hideSuggestions')) {
            LS_DEFS.suggestions.forEach(e => localStorage.setItem(e.key, e.value));
        }
        if (getSetting('hidePrimers')) {
            LS_DEFS.primers.forEach(e => localStorage.setItem(e.key, e.value));
        }
        if (getSetting('hideUpsells')) {
            LS_DEFS.upsells.forEach(e => localStorage.setItem(e.key, e.value));
        }
    }

    // --- CSS injection (runs at document-start, before DOM renders) ---

    function injectStyles() {
        const rules = [];

        if (getSetting('hideSuggestions')) {
            rules.push(
                `[data-testid="autosuggestion-container"] { display: none !important; }`,
                `.bg-raised:has([data-testid="autosuggestion-container"]) { display: none !important; }`,
                `[data-placement]:has([data-testid="autosuggestion-container"]) { display: none !important; }`,
                `div:has(> [data-placement] [data-testid="autosuggestion-container"]) { display: none !important; }`,
                `.rounded-b-none.border-b-none {
                    border-bottom-left-radius: 16px !important;
                    border-bottom-right-radius: 16px !important;
                    border-bottom-style: solid !important;
                }`
            );
        }

        if (getSetting('hidePrimers')) {
            rules.push(
                `.group\\/primer { display: none !important; }`,
                `[aria-label="Primer query categories"] { display: none !important; }`,
                `div.mt-lg.absolute.w-full:has(.group\\/primer) { display: none !important; }`,
                `div.mt-lg.absolute.w-full:has([aria-label="Primer query categories"]) { display: none !important; }`
            );
        }

        if (rules.length === 0) return;

        const style = document.createElement('style');
        style.id = 'pplx-never-suggest';
        style.textContent = rules.join('\n');
        (document.head || document.documentElement).appendChild(style);
    }

    // --- MutationObserver fallback (catches late-rendered elements) ---

    function startObserver() {
        const hideSuggestions = getSetting('hideSuggestions');
        const hidePrimers = getSetting('hidePrimers');
        if (!hideSuggestions && !hidePrimers) return;

        const startTime = Date.now();
        const observer = new MutationObserver(() => {
            // Re-enforce localStorage for the first 5s while Perplexity's JS initializes
            if (Date.now() - startTime < 5000) applySettings();

            if (hideSuggestions) {
                document.querySelectorAll('[data-testid="autosuggestion-container"]').forEach(el => {
                    const popup = el.closest('[data-placement]')?.parentElement || el;
                    if (popup.style.display !== 'none') popup.style.display = 'none';
                });
            }
            if (hidePrimers) {
                document.querySelectorAll('.group\\/primer, [aria-label="Primer query categories"]').forEach(el => {
                    const target = el.closest('.mt-lg.absolute') || el;
                    if (target.style.display !== 'none') target.style.display = 'none';
                });
            }
        });

        const start = () => {
            observer.observe(document.body, { childList: true, subtree: true });
        };

        if (document.body) start();
        else document.addEventListener('DOMContentLoaded', start);
    }

    // --- Menu commands ---

    GM_registerMenuCommand(`${getSetting('hideSuggestions') ? '✅' : '❌'} Hide Suggestions (typing)`, () => {
        setSetting('hideSuggestions', !getSetting('hideSuggestions'));
    });

    GM_registerMenuCommand(`${getSetting('hidePrimers') ? '✅' : '❌'} Hide Homepage Primers`, () => {
        setSetting('hidePrimers', !getSetting('hidePrimers'));
    });

    GM_registerMenuCommand(`${getSetting('hideUpsells') ? '✅' : '❌'} Hide Upsells & Banners`, () => {
        setSetting('hideUpsells', !getSetting('hideUpsells'));
    });

    // --- Init ---

    applySettings();
    injectStyles();
    startObserver();

})();