🎉 欢迎访问GreasyFork.Org 镜像站!本镜像站由公众号【爱吃馍】搭建,用于分享脚本。联系邮箱📮

Greasy fork 爱吃馍镜像

Greasy Fork is available in English.

📂 缓存分发状态(共享加速已生效)
🕒 页面同步时间:2026/01/15 10:17:02
🔄 下次更新时间:2026/01/15 11:17:02
手动刷新缓存

Simple Print LeetCode Problems

Removed unnecessary elements in the page for a clear PDF print of the leetcode question only

Tendrás que instalar una extensión para tu navegador como Tampermonkey, Greasemonkey o Violentmonkey si quieres utilizar este script.

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

Necesitarás instalar una extensión como Tampermonkey o Violentmonkey para instalar este script.

Necesitarás instalar una extensión como Tampermonkey o Userscripts para instalar este script.

Necesitará instalar una extensión como Tampermonkey para instalar este script.

Necesitarás instalar una extensión para administrar scripts de usuario si quieres instalar este script.

(Ya tengo un administrador de scripts de usuario, déjame instalarlo)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

Necesitará instalar una extensión como Stylus para instalar este estilo.

Necesitará instalar una extensión como Stylus para instalar este estilo.

Necesitará instalar una extensión como Stylus para instalar este estilo.

Necesitará instalar una extensión del gestor de estilos de usuario para instalar este estilo.

Necesitará instalar una extensión del gestor de estilos de usuario para instalar este estilo.

Necesitará instalar una extensión del gestor de estilos de usuario para instalar este estilo.

(Ya tengo un administrador de estilos de usuario, déjame instalarlo)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

// ==UserScript==
// @name         Simple Print LeetCode Problems
// @namespace    https://greasyfork.org/en/users/114838-groundzyy
// @version      0.3.3.31
// @description  Removed unnecessary elements in the page for a clear PDF print of the leetcode question only
// @author       groundzyy
// @match        https://leetcode.com/problems/*
// ==/UserScript==

function waitForKeyElements (
    selectorTxt,    /* Required: The jQuery selector string that
                        specifies the desired element(s).
                    */
    actionFunction, /* Required: The code to run when elements are
                        found. It is passed a jNode to the matched
                        element.
                    */
    bWaitOnce,      /* Optional: If false, will continue to scan for
                        new elements even after the first match is
                        found.
                    */
    iframeSelector  /* Optional: If set, identifies the iframe to
                        search.
                    */
) {
    var targetNodes, btargetsFound;

    if (typeof iframeSelector == "undefined")
        targetNodes     = $(selectorTxt);
    else
        targetNodes     = $(iframeSelector).contents ()
                                           .find (selectorTxt);

    if (targetNodes  &&  targetNodes.length > 0) {
        btargetsFound   = true;
        /*--- Found target node(s).  Go through each and act if they
            are new.
        */
        targetNodes.each ( function () {
            var jThis        = $(this);
            var alreadyFound = jThis.data ('alreadyFound')  ||  false;

            if (!alreadyFound) {
                //--- Call the payload function.
                var cancelFound     = actionFunction (jThis);
                if (cancelFound)
                    btargetsFound   = false;
                else
                    jThis.data ('alreadyFound', true);
            }
        } );
    }
    else {
        btargetsFound   = false;
    }

    //--- Get the timer-control variable for this selector.
    var controlObj      = waitForKeyElements.controlObj  ||  {};
    var controlKey      = selectorTxt.replace (/[^\w]/g, "_");
    var timeControl     = controlObj [controlKey];

    //--- Now set or clear the timer as appropriate.
    if (btargetsFound  &&  bWaitOnce  &&  timeControl) {
        //--- The only condition where we need to clear the timer.
        clearInterval (timeControl);
        delete controlObj [controlKey]
    }
    else {
        //--- Set a timer, if needed.
        if ( ! timeControl) {
            timeControl = setInterval ( function () {
                    waitForKeyElements (    selectorTxt,
                                            actionFunction,
                                            bWaitOnce,
                                            iframeSelector
                                        );
                },
                300
            );
            controlObj [controlKey] = timeControl;
        }
    }
    waitForKeyElements.controlObj   = controlObj;
}

waitForKeyElements (
    "div.like-and-dislike"
    , commentCallbackFunction
);

//--- Page-specific function to do what we want when the node is found.
function commentCallbackFunction (jNode) {

    $('div.content-wrapper > div.navbar').remove();

    var diff = $('#desktop-side-bar div ul.side-bar-list li:nth-child(2) span:nth-child(2)').text();
    $('.question-title h3').text($('.question-title h3').text() + ' (' + diff + ')');

    $('head title').text($('.question-title h3').text().trim().replace('.', ''));
    $('div.like-and-dislike').parent().remove();
    $('nav.tab-view').parent().remove();
    $('div.action-btn-base').remove();
    $('div#interviewed-div').remove();
    $('div.question-detail-bottom').parent().remove();
    $('div.notepad-wrapper').remove();
    $('div#notepad-container').remove();
    $('div#lc_navbar_placeholder').remove();
    $('#supportModal').remove();
    $('div.CreateModal-base').remove();
    $('#lc-alert-container').remove();
    $('.showspoilers').remove();
    $('#MathJax_Message').remove();


    if ($('#tags-company a')) {
        $('#tags-company').html('Companies: ' + $('#tags-company').html());
        $('.question-panel').append($('#tags-company'));
    }
    if ($('#tags-topic a')) {
        $('#tags-topics').html('Topics: ' + $('#tags-topics').html());
        $('.question-panel').append($('#tags-topics'));
    }
    if ($('#tags-question a')) {
        $('#tags-question').html('Similar Questions: ' + $('#tags-question').html());
        $('.question-panel').append($('#tags-question'));
    }
    $('footer').remove();
    $('#desktop-side-bar').remove();

    $('body').css('font-size', '24px');
    $('body').css('line-height', '24px');
    $('.question-title').css('margin-top', '2px');
    $('.spoilers').css('display', '');
    $('pre').css('font-size', '24px');
    $('pre').css('white-space', 'pre-wrap');
    $('a.btn-primary').css('font-size', '18px');
    $('div.question-title h3').css('font-size', '32px');
    $('p').css('margin-bottom', '20px');
    $('p').css('margin-top', '20px');
    $('div.content-wrapper').css('padding-bottom', '0px');

    $('div a').removeClass('text-sm btn-xs label text-sm label-M label-E');
    $('#tags-company a').addClass('text-lg');
    $('#tags-topics a').addClass('text-lg');
    $('div a').removeClass('round');
    $('#tags-question a').addClass('text-lg btn btn-default btn-round text-lg');
    $('div > a').removeAttr("href");

    $('a').removeClass("label-Easy");
    $('a').removeClass("label-Medium");
    $('a').removeClass("label-Hard");

    $('div#tags-company, div#tags-topics, div#tags-question').css('font-size', '14px');
    $('div a.btn').removeClass('sidebar-tag text-lg');

};