// ==UserScript== // @name CSDN屏蔽会员资源 // @namespace eyes // @version 1.3 // @description 专门屏蔽需要积分才能下载的资源页面以及会员专属资源的页面,让白嫖党在CSDN拥有更舒适的体验 // @author eyes // @match *://*.csdn.net/* // @grant none // @downloadURL none // ==/UserScript== (function () { 'use strict'; // 油猴脚本里似乎必须绑定事件才能执行,我试了很多种加载完成执行都没用。。。。我也没办法只能这样。。。。。感觉这是个bug var loc = location.href; // 搜索页面 var reg = /\/so\/search/g; if (reg.test(loc)) { // 执行屏蔽 function search_shield() { var list_item = $('.list-item'); var clear_num = 0; $.each(list_item, function (i, v) { var b = v.getElementsByClassName('icon-download').length; if (b && v.style.display != 'none') { v.style.display = 'none'; clear_num++; } var b2 = v.getElementsByClassName('download-size').length; if (b2 && v.style.display != 'none') { v.style.display = 'none'; clear_num++; } }) return clear_num; } // 初始时执行 $(document).mousemove(function() { var clear_num = search_shield(); if (clear_num) { console.log("初次屏蔽", clear_num, "个会员资源链接╮( ̄▽  ̄)╭"); $(document).off("mousemove"); } }) // 页面下滑加载时执行 $(window).scroll(function () { var clear_num = search_shield(); if (clear_num) console.log("再次屏蔽", clear_num, "个会员资源链接╮( ̄▽  ̄)╭"); }) // 点击加载更多时执行 $(".so-load-data").click(function () { var clear_num = search_shield(); if (clear_num) console.log("再次屏蔽", clear_num, "个会员资源链接╮( ̄▽  ̄)╭"); }) } // 文章页面 var reg2 = /article\/details/g; if (reg2.test(loc)) { // 执行屏蔽 function article_shield() { var clear_num = 0; var download_item = $('.recommend-box .type_download'); $.each(download_item, function (i, v) { v.style.display = 'none'; clear_num++; }) var download_type = $("[data-type='download']"); $.each(download_type, function (i, v) { v.style.display = 'none'; clear_num++; }) return clear_num; } $(document).mousemove(function() { var clear_num = article_shield(); if (clear_num) { console.log("一共屏蔽", clear_num, "个会员资源链接╮( ̄▽  ̄)╭"); $(document).off("mousemove"); } }) } })();