CSDN 1-Click Downloader

1-Click Download CSDN pages to PDF

2024-07-18 기준 버전입니다. 최신 버전을 확인하세요.

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

// ==UserScript==
// @name         CSDN 1-Click Downloader
// @namespace    https://github.com/ySpica
// @version      1.2
// @description  1-Click Download CSDN pages to PDF
// @author       Spica Yeung
// @connect      www.csdn.net
// @match        https://blog.csdn.net/*/article/details/*
// @icon         none
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    // Create a wrapper div for hover detection
    const hoverArea = document.createElement('div');
    hoverArea.style.position = 'fixed';
    hoverArea.style.left = '0';
    hoverArea.style.bottom = '0';
    hoverArea.style.width = '100px'; // Hover area width
    hoverArea.style.height = '100px'; // Hover area height
    hoverArea.style.zIndex = 999;
    hoverArea.style.background = 'transparent';
    document.body.appendChild(hoverArea);

    // Add a button to the page
    const button = document.createElement('button');
    button.textContent = '↡';
    button.style.position = 'fixed';
    button.style.left = '10px';
    button.style.bottom = '10px';
    button.style.zIndex = 1000;
    button.style.padding = '7.5px 15px';
    button.style.fontSize = '1.5em';
    button.style.background = 'white';
    button.style.border = '1px solid #ccc';
    button.style.cursor = 'pointer';
    button.style.display = 'none';
    document.body.appendChild(button);

    // Show the button when hovering over the hover area
    hoverArea.onmouseover = function() {
        button.style.display = 'block';
    };

    // Hide the button when not hovering over the button or the hover area
    hoverArea.onmouseout = function() {
        if (!button.matches(':hover')) {
            button.style.display = 'none';
        }
    };

    button.onmouseout = function() {
        if (!hoverArea.matches(':hover')) {
            button.style.display = 'none';
        }
    };

    button.onclick = function() {
        button.style.display = 'none'; // Hide the button after clicking
        $("#side").remove();
        $("#comment_title, #comment_list, #comment_bar, #comment_form, .announce, #ad_cen, #ad_bot").remove();
        $(".nav_top_2011, #header, #navigator").remove();
        $(".p4course_target, .comment-box, .recommend-box, #csdn-toolbar, #tool-box").remove();
        $("aside").remove();
        $(".tool-box").remove();
        $("#toolBarBox").remove();
        $("main").css('display', 'block');
        $("main").css('float', 'none');
        $(".option-box").remove();
        $("body").css('min-width', '0');
        window.print();
    };
})();