// ==UserScript== // @name 网页精灵 // @name:en WebSpirit // @name:zh 网页精灵 // @name:zh-CN 网页精灵 // @name:zh-TW 網頁精靈 // @name:ja ウェブのエルフ // @namespace http://tampermonkey.net/ // @version 1.2 // @description 展开全文,去防盗链广告 // @description:en Expand the full text, remove the anti-theft chain and advertising // @description:zh 展开全文,去防盗链广告 // @description:zh-CN 展开全文,去防盗链广告 // @description:zh-TW 展開全文,去防盜鏈廣告 // @description:ja フルテキストを展開し、盗難防止チェーンと広告を削除します // @author Obrain Face // @exclude *://www.baidu.com/* // @match *://www.360doc.com/* // @match *://www.360doc.cn/* // @match *://www.csdn.net/* // @match *://blog.csdn.net/* // @match *://*.iteye.com/* // @match *://mp.weixin.qq.com/* // @match *://www.jianshu.com/* // @match *://www.w3school.com.cn/* // @match *://dict.youdao.com/* // @match *://baijiahao.baidu.com/* // @match *://www.w3school.com.cn/* // @match *://baike.baidu.com/* // @match *://zhidao.baidu.com/* // @match *://ke.qq.com/* // @match *://sourceforge.net/* // @match *://blog.51cto.com/* // @grant none // @require https://code.jquery.com/jquery-3.1.1.min.js // @downloadURL https://update.greasyfork.icu/scripts/404065/%E7%BD%91%E9%A1%B5%E7%B2%BE%E7%81%B5.user.js // @updateURL https://update.greasyfork.icu/scripts/404065/%E7%BD%91%E9%A1%B5%E7%B2%BE%E7%81%B5.meta.js // ==/UserScript== //引用的jquery的版本不能太高,高过1.12.1的版本(https://code.jquery.com/ui/1.12.1/jquery-ui.min.js)在百度按时间段搜索时报错Uncaught TypeError: $.limitWd is not a function //但是此版本也会报错Execution of script 'New Userscript' failed! jQuery is not defined,但不影响百度按时间段搜索 //后来发现低版本jquery在处理360doc页面的“展开全文”时,又会出现设置backgroundcolor错误,但是此脚本没有处理这个,报错原因暂时不得知。真是按下葫芦又起瓢。 //最终还是改为高版本的jquery,同时用@exclude排除百度,以解决百度按时间段搜索时报错的问题。 (function() { 'use strict'; // Your code here... var targetUrl = window.location.href; //去除CSDN“展开阅读全文” if(targetUrl.indexOf("blog.csdn.net") != -1){ // var readmoreBtn = document.getElementById("btn-readmore"); //方法1:模拟点击事件,触发请求 // readmoreBtn.click(); //方法2:CSS处理 var myElements = document.getElementsByClassName("hide-article-box"); var myElement = myElements[0]; var contentDiv =document.getElementById('article_content'); contentDiv.removeAttribute("style"); myElement.remove(); //ajaxPost(); //XHRPost(); /* 总结:可以看出在油猴中使用postman请求自动生成的ajax和XHR都能成功向CSDN发送请求,但是使用w3school的测试页http://www.w3school.com.cn/tiy/t.asp?f=html5_ev_onload 和本地html代码测试页file:///C:/Users/alex/Desktop/testFIleUpload/httpWithHeader.html都会有跨域问题、请求头referer和origin不安全的提示。 */ /* //使用style.display="none"的处理方法不可用,虽可去除“展开阅读全文”按钮,但导致文章加载不全 myElement.style.display="none";//隐藏 */ //去除csdn博客复制时剪贴板劫持(复制内容后追加作者版权说明等多余内容) if (typeof (csdn) != "undefined") { console.log("开始清除csdn博客剪贴板------"); csdn.copyright.init("", "", ""); //去除剪贴板劫持 } // $(".check-adblock-bg").hide(); var hookedInterval = window.setInterval; //拦截页面一切定时器,过于霸道可能会有误伤 window.setInterval = function(callback, seconds) { // Magic time if (seconds == 1e3) { document.querySelector('#check-adblock-time').remove(); return; } hookedInterval(callback, seconds); }; window.csdn.anonymousUserLimit.judgment = function() { return true; }; window.csdn.anonymousUserLimit.Jumplogin = function () { console.log("Fuck CSDN :)"); }; } //去除www.csdn.net的“展开阅读原文” if(targetUrl.indexOf("www.csdn.net") != -1){ $('.readmore_btn')[0].click(); } //去除360doc.com“展开全文” if(targetUrl.indexOf("www.360doc.com") != -1){ $('body').removeClass('articleMaxH'); } //去除360doc.cn“展开剩余内容” if(targetUrl.indexOf("www.360doc.cn") != -1){ $('.mip-showmore-btn').click(); } //去除iteye.com“阅读更多” if(targetUrl.indexOf("iteye.com") != -1){ $('.hide-main-content').removeAttr('style'); $('.hide-article-box').hide(); } //去除blog.51cto.com博客打开时弹出的广告 if(targetUrl.indexOf("blog.51cto.com") != -1){ $(".closeMB").each(function(){ if(!$(this).attr("target")=="_blank"){ $(this).click(); } }); } })(); $(document).ready(function(){ //需等到页面dom加载完毕才能使属性值替换 var targetUrl = window.location.href; //mp.weixin.qq.com反微信公众号文章图片防盗链 if(targetUrl.indexOf("mp.weixin.qq.com") != -1){ $("img").each(function(){ $(this).attr("src",$(this).attr("data-src")); //$("img").removeAttr("data-src"); }); } //www.jianshu.com反简书文章图片防盗链 if(targetUrl.indexOf("www.jianshu.com") != -1){ $("img").each(function(){ $(this).attr("src",$(this).attr("data-original-src")); //$("img").removeAttr("data-original-src"); }); } //www.w3school.com.cn去广告 if(targetUrl.indexOf("www.w3school.com.cn") != -1){ $("#ad").remove(); } //dict.youdao.com去广告 if(targetUrl.indexOf("dict.youdao.com") != -1){ $("#ads").remove(); $("#topImgAd").remove(); } //baijiahao.baidu.com图片防盗链去除 if(targetUrl.indexOf("baijiahao.baidu.com") != -1){ $("img").each(function(){ if($(this).attr("src").indexOf(".jpeg")==-1 && $(this).attr("src").indexOf(".jpg")==-1 && $(this).attr("alt").indexOf("到百度首页")==-1){ $(this).attr("src",$(this).attr("src").split("?")[0]+".jpg"); } }); } //www.w3school.com.cn添加