油猴脚本·CSDN文库免登陆阅读全文解锁鼠标

2024-3-10 / 0 评论 / 25 阅读

CSDN文库阅读全文,去除VIP登录遮罩,解锁鼠标复制功能
注意,是文库,文库。这几天查资料搜索软件反复给了csdn链接,大家都知道我最烦登录框。。。

使用方法:复制下方代码,如图操作即可食用!

// ==UserScript==
// @name         CSDN文库免vip阅读全文,解锁复制限制
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  CSDN文库阅读全文,去除VIP登录遮罩,解锁鼠标复制功能
// @author       icescat
// @match        *://*.csdn.net/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    const adjustArticle = () => {
        // 移除遮罩层
        document.querySelectorAll('.open, .vip').forEach(el => el.remove());

        // 展开被限制高度的内容
        const articleContainer = document.querySelector('.article-box .cont.first-show[data-v-6487a68f]');
        if (articleContainer) {
            articleContainer.style.maxHeight = 'none';
        }
    };

    // 启用复制功能
    const enableCopy = () => {
        document.body.oncopy = null;
        document.oncopy = null;
        document.querySelectorAll('*').forEach(el => {
            el.style.userSelect = 'auto';
        });
    };

    // 使用MutationObserver来监视文档的变化
    const observer = new MutationObserver((mutations) => {
        mutations.forEach((mutation) => {
            if (mutation.addedNodes.length) {
                adjustArticle();
                enableCopy();
            }
        });
    });

    observer.observe(document.body, {
        childList: true,
        subtree: true
    });

    // 页面加载时尝试执行一次
    window.addEventListener('load', () => {
        adjustArticle();
        enableCopy();
    });
})();

 

 
×

如果觉得文章对您有用,请随意打赏。
您的支持是我们继续创作的动力!

微信打赏

微信扫一扫

支付宝打赏

支付宝扫一扫

扫描二维码,在手机上阅读

评论一下?

OωO
取消