tampermonkey 如何引用Jquery+CSDN阅读模式案例

本文介绍了如何在Tampermonkey中引用jQuery,通过添加@require指令并指定jQuery的官方CDN地址,以实现CSDN阅读模式的功能。简单易懂的步骤帮助用户改善CSDN的阅读体验。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >


打开你的 tampermonkey 然后 

在 标题头上面添加 @require 后面是一个jq的文件地址。你可以查找Jquery的官方CDN加速。

// @require    http://code.jquery.com/jquery-1.11.0.min.js

 

测试:CSDN阅读模式;

(function() {
    'use strict';
        var fa=$("body");
        var btn=$("<li></li>");
        var json={
            "background":"#31e16d",
            "height":"16px",
            "padding":"5px",
            "cursor": "pointer",
            "top":"300px",
            "right":"80px",
            "position": "fixed"
        };
        btn.css(json);
        btn.html("<span id='lfsenior'>开启阅读模式</span>");
        fa.append(btn);
        var bodywidth=$("#body").css("width");
        var mainwidth=$("#main").css("width");
        btn.click(function () {
            if($("#lfsenior").html()=="开启阅读模式"){
                $("#lfsenior").html("关闭阅读模式");
                $("#body").css("width","100%");
                $("#main").css("width","100%");
                $(".csdn-tracking-statistics").hide();
                $("#article_content").siblings(".similar_article").hide();
                $("#res-relatived").hide();
                $("#side").hide();
                $("#comment_title").parent("div").hide();
                $("#pub_footerall").parent("div").hide();
            }else{
                console.log(3435);
                console.log(456);
                $("#lfsenior").html("开启阅读模式");
                $("#body").css("width",bodywidth);
                $("#main").css("width",mainwidth);
                $(".csdn-tracking-statistics").show(1000);
                $("#article_content").siblings(".similar_article").show(1000);
                $("#res-relatived").show(1000);
                $("#side").show(1000);
                $("#comment_title").parent("div").show(1000);
                $("#pub_footerall").parent("div").show(1000);
            }
        });
    // Your code here...
})();

 

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值