上一主题 下一主题
ScriptCat,新一代的脚本管理器脚本站,与全世界分享你的用户脚本油猴脚本开发指南教程目录
返回列表 发新帖
楼主: wwwwwllllk - 

csdn屏幕需要下载的资源文章

[复制链接]
  • TA的每日心情
    无聊
    2023-11-2 17:37
  • 签到天数: 275 天

    [LV.8]以坛为家I

    107

    主题

    438

    回帖

    944

    积分

    荣誉开发者

    积分
    944

    荣誉开发者油中2周年卓越贡献生态建设者

    发表于 2022-4-27 22:48:52 | 显示全部楼层 | 阅读模式
    安装此脚本 如何安装? 脚本问题反馈 给脚本评分 查看代码
    
    // ==UserScript==
    // @name         把csdn需要下载的资源屏蔽掉
    // @namespace    http://tampermonkey.net/
    // @version      0.1
    // @description  解决了我们搜索文章的列表,以及点击查看博客以后下面会显示一些推荐的文章。这里把需要下载的隐藏掉了。这里先用。没什么问题我就把csdn的内容都写到一个脚本里面
    // @author       You
    // @match        https://blog.csdn.net/*
    // @match        https://so.csdn.net/so/search?*
    // @icon         https://www.google.com/s2/favicons?sz=64&domain=csdn.net
    // @grant        none
    // ==/UserScript==
    
    (function() {
        'use strict';
        let csdnSearchUrl = /so\/search/i;
    
        setTimeout(()=>{
          if(window.location.href.match(csdnSearchUrl)){
              // 思路就是我拿到有下载图标的标签,然后我把标签的大盒子删掉,然后就是盒子的父亲的父亲最后定位找到的。设置3s以后执行,防止拿不到标签
              // 这里本来是用remove的但是用remove会导致集合数组的长度实时变化,所以这里用display为node来改变
            let allDownLoadUrlList = document.getElementsByClassName("icon-download");
            let allDownLoadUrlListLength = allDownLoadUrlList.length;
            console.log(allDownLoadUrlList)
            console.log(allDownLoadUrlList.length)
            for(let i=0;i < allDownLoadUrlListLength;i++){
                console.log(i)
                allDownLoadUrlList[i].parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.style.display="none";
            }
            setInterval(()=>{
                // 出现下拉的时候会有新的出现,所以这里用setInterval,其实这里用监控滚动实现比较好。后面可能优化。也可能懒就不动了
                let allDownLoadUrlList = document.getElementsByClassName("icon-download");
                let allDownLoadUrlListLength = allDownLoadUrlList.length;
                console.log(allDownLoadUrlList)
                console.log(allDownLoadUrlList.length)
                for(let i=0;i < allDownLoadUrlListLength;i++){
                    console.log(i)
                    allDownLoadUrlList[i].parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.style.display="none";
                }
            },10*1000)
          }else{
              // 这个是文章下面出现下载的资源,敲好这个标签表示的就是下载的文章
              let allNeedDownLoadAboutArticleUndle = document.getElementsByClassName("type_download ");
              for(let i=0;i<allNeedDownLoadAboutArticleUndle.length;i++){
                  allNeedDownLoadAboutArticleUndle[i].style.display="none"
              }
    
          }
    
        },3000)
    
        // Your code here...
    })();
    I frequently record, because want to leave something.

    发表回复

    本版积分规则

    快速回复 返回顶部 返回列表