网页精灵

展开全文,去防盗链广告

  1. // ==UserScript==
  2. // @name 网页精灵
  3. // @name:en WebSpirit
  4. // @name:zh 网页精灵
  5. // @name:zh-CN 网页精灵
  6. // @name:zh-TW 網頁精靈
  7. // @name:ja ウェブのエルフ
  8.  
  9. // @namespace http://tampermonkey.net/
  10. // @version 1.2
  11. // @description 展开全文,去防盗链广告
  12. // @description:en Expand the full text, remove the anti-theft chain and advertising
  13. // @description:zh 展开全文,去防盗链广告
  14. // @description:zh-CN 展开全文,去防盗链广告
  15. // @description:zh-TW 展開全文,去防盜鏈廣告
  16. // @description:ja フルテキストを展開し、盗難防止チェーンと広告を削除します
  17.  
  18. // @author Obrain Face
  19.  
  20. // @exclude *://www.baidu.com/*
  21. // @match *://www.360doc.com/*
  22. // @match *://www.360doc.cn/*
  23. // @match *://www.csdn.net/*
  24. // @match *://blog.csdn.net/*
  25. // @match *://*.iteye.com/*
  26. // @match *://mp.weixin.qq.com/*
  27. // @match *://www.jianshu.com/*
  28. // @match *://www.w3school.com.cn/*
  29. // @match *://dict.youdao.com/*
  30. // @match *://baijiahao.baidu.com/*
  31. // @match *://www.w3school.com.cn/*
  32. // @match *://baike.baidu.com/*
  33. // @match *://zhidao.baidu.com/*
  34. // @match *://ke.qq.com/*
  35. // @match *://sourceforge.net/*
  36. // @match *://blog.51cto.com/*
  37.  
  38. // @grant none
  39. // @require https://code.jquery.com/jquery-3.1.1.min.js
  40. // ==/UserScript==
  41. //引用的jquery的版本不能太高,高过1.12.1的版本(https://code.jquery.com/ui/1.12.1/jquery-ui.min.js)在百度按时间段搜索时报错Uncaught TypeError: $.limitWd is not a function
  42. //但是此版本也会报错Execution of script 'New Userscript' failed! jQuery is not defined,但不影响百度按时间段搜索
  43. //后来发现低版本jquery在处理360doc页面的“展开全文”时,又会出现设置backgroundcolor错误,但是此脚本没有处理这个,报错原因暂时不得知。真是按下葫芦又起瓢。
  44. //最终还是改为高版本的jquery,同时用@exclude排除百度,以解决百度按时间段搜索时报错的问题。
  45. (function() {
  46. 'use strict';
  47.  
  48. // Your code here...
  49. var targetUrl = window.location.href;
  50. //去除CSDN“展开阅读全文”
  51. if(targetUrl.indexOf("blog.csdn.net") != -1){
  52. // var readmoreBtn = document.getElementById("btn-readmore");
  53. //方法1:模拟点击事件,触发请求
  54. // readmoreBtn.click();
  55.  
  56. //方法2:CSS处理
  57. var myElements = document.getElementsByClassName("hide-article-box");
  58. var myElement = myElements[0];
  59. var contentDiv =document.getElementById('article_content');
  60. contentDiv.removeAttribute("style");
  61. myElement.remove();
  62. //ajaxPost();
  63. //XHRPost();
  64. /*
  65. 总结:可以看出在油猴中使用postman请求自动生成的ajax和XHR都能成功向CSDN发送请求,但是使用w3school的测试页http://www.w3school.com.cn/tiy/t.asp?f=html5_ev_onload
  66. 和本地html代码测试页file:///C:/Users/alex/Desktop/testFIleUpload/httpWithHeader.html都会有跨域问题、请求头referer和origin不安全的提示。
  67. */
  68. /*
  69. //使用style.display="none"的处理方法不可用,虽可去除“展开阅读全文”按钮,但导致文章加载不全
  70. myElement.style.display="none";//隐藏
  71. */
  72.  
  73. //去除csdn博客复制时剪贴板劫持(复制内容后追加作者版权说明等多余内容)
  74. if (typeof (csdn) != "undefined") {
  75. console.log("开始清除csdn博客剪贴板------");
  76. csdn.copyright.init("", "", ""); //去除剪贴板劫持
  77. }
  78. // $(".check-adblock-bg").hide();
  79. var hookedInterval = window.setInterval;
  80. //拦截页面一切定时器,过于霸道可能会有误伤
  81. window.setInterval = function(callback, seconds) {
  82. // Magic time
  83. if (seconds == 1e3) {
  84. document.querySelector('#check-adblock-time').remove();
  85. return;
  86. }
  87. hookedInterval(callback, seconds);
  88. };
  89. window.csdn.anonymousUserLimit.judgment = function() {
  90. return true;
  91. };
  92. window.csdn.anonymousUserLimit.Jumplogin = function () {
  93. console.log("Fuck CSDN :)");
  94. };
  95. }
  96.  
  97. //去除www.csdn.net的“展开阅读原文”
  98. if(targetUrl.indexOf("www.csdn.net") != -1){
  99. $('.readmore_btn')[0].click();
  100. }
  101.  
  102. //去除360doc.com“展开全文”
  103. if(targetUrl.indexOf("www.360doc.com") != -1){
  104. $('body').removeClass('articleMaxH');
  105. }
  106. //去除360doc.cn“展开剩余内容”
  107. if(targetUrl.indexOf("www.360doc.cn") != -1){
  108. $('.mip-showmore-btn').click();
  109. }
  110. //去除iteye.com“阅读更多”
  111. if(targetUrl.indexOf("iteye.com") != -1){
  112. $('.hide-main-content').removeAttr('style');
  113. $('.hide-article-box').hide();
  114. }
  115. //去除blog.51cto.com博客打开时弹出的广告
  116. if(targetUrl.indexOf("blog.51cto.com") != -1){
  117. $(".closeMB").each(function(){
  118. if(!$(this).attr("target")=="_blank"){
  119. $(this).click();
  120. }
  121. });
  122. }
  123. })();
  124.  
  125. $(document).ready(function(){
  126. //需等到页面dom加载完毕才能使属性值替换
  127. var targetUrl = window.location.href;
  128. //mp.weixin.qq.com反微信公众号文章图片防盗链
  129. if(targetUrl.indexOf("mp.weixin.qq.com") != -1){
  130. $("img").each(function(){
  131. $(this).attr("src",$(this).attr("data-src"));
  132. //$("img").removeAttr("data-src");
  133. });
  134. }
  135. //www.jianshu.com反简书文章图片防盗链
  136. if(targetUrl.indexOf("www.jianshu.com") != -1){
  137. $("img").each(function(){
  138. $(this).attr("src",$(this).attr("data-original-src"));
  139. //$("img").removeAttr("data-original-src");
  140. });
  141. }
  142. //www.w3school.com.cn去广告
  143. if(targetUrl.indexOf("www.w3school.com.cn") != -1){
  144. $("#ad").remove();
  145. }
  146. //dict.youdao.com去广告
  147. if(targetUrl.indexOf("dict.youdao.com") != -1){
  148. $("#ads").remove();
  149. $("#topImgAd").remove();
  150. }
  151. //baijiahao.baidu.com图片防盗链去除
  152. if(targetUrl.indexOf("baijiahao.baidu.com") != -1){
  153. $("img").each(function(){
  154. if($(this).attr("src").indexOf(".jpeg")==-1 && $(this).attr("src").indexOf(".jpg")==-1 && $(this).attr("alt").indexOf("到百度首页")==-1){
  155. $(this).attr("src",$(this).attr("src").split("?")[0]+".jpg");
  156. }
  157. });
  158. }
  159. //www.w3school.com.cn添加<script>标签以便引用jQuery
  160. if(targetUrl.indexOf("www.w3school.com.cn") != -1){
  161. //document.getElementById("TestCode").innerHTML.split("&lt;html&gt;")[0];
  162. var testCodeHtmlStr = $("#TestCode").html()+"";
  163. if(testCodeHtmlStr.indexOf('src="/jquery/jquery.js"')!=-1){
  164. return;
  165. }
  166. $("#TestCode").html($("#TestCode").html().split("&lt;script&gt;")[0]+"&lt;script src=&quot;https://code.jquery.com/jquery-3.1.1.min.js&quot;&gt;&lt;/script&gt;&lt;script&gt;"+$("#TestCode").html().split("&lt;script&gt;")[1]);
  167. }
  168. //baike.baidu.com跳转到指定词条标题处,以便直接阅读百科
  169. if(targetUrl.indexOf("baike.baidu.com") != -1){
  170. $(".top-tool").attr("id","tiaozhuanId");
  171. $(window).scrollTop($('#tiaozhuanId').offset().top);
  172. }
  173. //zhidao.baidu.com查看“更多回答”
  174. if(targetUrl.indexOf("zhidao.baidu.com") != -1){
  175. $("#show-answer-hide").click();
  176. $(".wgt-best-showbtn").click();//最好答案(此行代码居然不起作用?)
  177. //document.getElementsByClassName("wgt-best-showbtn")[0].click();//最好答案(此行代码居然不起作用?)
  178. if($(".wgt-answers-showbtn").length>0){
  179. $(".wgt-answers-showbtn").click();//其他答案(此行代码居然不起作用?)
  180. }
  181. }
  182. //ke.qq.com去掉“xxx(QQ号)正在观看”弹幕水印
  183. if(targetUrl.indexOf("ke.qq.com") != -1){
  184. console.log("开始清除QQ号弹幕水印===========");
  185. $("#marquee").remove();
  186. setTimeout($("#marquee").remove(),1000*60*10);
  187. /**
  188. var count = 0;
  189. var sbTx = setInterval(function(){
  190. count++;
  191. var txDd = document.querySelectorAll("[class^='player-inject']")
  192. if(txDd.length || count > 300) {
  193. txDd[0].style.opacity = 0;
  194. txDd[0].style.position = 'absolute';
  195. txDd[0].style.top = '-100000px';
  196. clearInterval(sbTx)
  197. }
  198. },500)
  199. */
  200. console.log("清除QQ号弹幕水印完毕!===========");
  201. }
  202. //sourceforge.net去掉搜索结果首条广告
  203. if(targetUrl.indexOf("sourceforge.net") != -1){
  204. $(".nel.standard.can-truncate").remove();
  205. }
  206. //打印当前页面引用的所有js脚本文件
  207. var tags = document.getElementsByTagName("script");
  208. for (var i=0; i<tags.length; )
  209. {
  210. if(tags[i].hasAttribute("src")){
  211. console.log(tags[i].getAttribute("src") );
  212. }
  213. i++;
  214. }
  215. });
  216.  
  217. //发送ajax请求到CSDN
  218. //postman根据请求自动生成的ajax请求
  219. function ajaxPost()
  220. {
  221. var form = new FormData();
  222. form.append("headers", "{\"component\":\"enterprise\",\"datatype\":\"re\",\"version\":\"v1\"}");
  223. form.append("body", "\"{\\\"re\\\":\\\"uid=superit401&ref=https%3A%2F%2Fblog.csdn.net%2Fhunter___%2Farticle%2Fdetails%2F85019938&pid=blog&mod=popu_376&con=%2Chttps%3A%2F%2Fblog.csdn.net%2Fjayandchuxu%2Farticle%2Fdetails%2F79113755%2C%2Ctop_0&ck=%2Chttps%3A%2F%2Fblog.csdn.net%2Fjayandchuxu%2Farticle%2Fdetails%2F79113755%2C%2Ctop_0&curl=https%3A%2F%2Fblog.csdn.net%2Fjayandchuxu%2Farticle%2Fdetails%2F79113755%23%E7%AC%AC-2-%E7%AB%A0-%E7%BC%96%E5%86%99%E7%AC%AC%E4%B8%80%E4%B8%AA%E7%94%A8%E6%88%B7%E8%84%9A%E6%9C%AC&session_id=10_1561430276375.632503&type=click\\\"}\"");
  224.  
  225. var settings = {
  226. "async": true,
  227. "crossDomain": true,
  228. "url": "https://re.csdn.net/csdnbi",
  229. "method": "POST",
  230. "headers": {
  231. "referer": "https://blog.csdn.net/jayandchuxu/article/details/79113755",
  232. "origin": "https://blog.csdn.net",
  233. "cache-control": "no-cache"
  234. },
  235. "processData": false,
  236. "contentType": false,
  237. "mimeType": "multipart/form-data",
  238. "data": form
  239. };
  240.  
  241. $.ajax(settings).done(function (response) {
  242. console.log(response);
  243. alert(response);
  244. });
  245.  
  246. }
  247.  
  248. //postman根据请求自动生成的xhr请求
  249. function XHRPost()
  250. {
  251. var data = new FormData();
  252. data.append("headers", "{\"component\":\"enterprise\",\"datatype\":\"re\",\"version\":\"v1\"}");
  253. data.append("body", "\"{\\\"re\\\":\\\"uid=superit401&ref=https%3A%2F%2Fblog.csdn.net%2Fhunter___%2Farticle%2Fdetails%2F85019938&pid=blog&mod=popu_376&con=%2Chttps%3A%2F%2Fblog.csdn.net%2Fjayandchuxu%2Farticle%2Fdetails%2F79113755%2C%2Ctop_0&ck=%2Chttps%3A%2F%2Fblog.csdn.net%2Fjayandchuxu%2Farticle%2Fdetails%2F79113755%2C%2Ctop_0&curl=https%3A%2F%2Fblog.csdn.net%2Fjayandchuxu%2Farticle%2Fdetails%2F79113755%23%E7%AC%AC-2-%E7%AB%A0-%E7%BC%96%E5%86%99%E7%AC%AC%E4%B8%80%E4%B8%AA%E7%94%A8%E6%88%B7%E8%84%9A%E6%9C%AC&session_id=10_1561430276375.632503&type=click\\\"}\"");
  254.  
  255. var xhr = new XMLHttpRequest();
  256. xhr.withCredentials = true;
  257.  
  258. xhr.addEventListener("readystatechange", function () {
  259. if (this.readyState === 4) {
  260. console.log(this.responseText);
  261. alert(this.responseText);
  262. }
  263. });
  264.  
  265. xhr.open("POST", "https://re.csdn.net/csdnbi");
  266. xhr.setRequestHeader("referer", "https://blog.csdn.net/jayandchuxu/article/details/79113755");
  267. xhr.setRequestHeader("origin", "https://blog.csdn.net");
  268. xhr.setRequestHeader("cache-control", "no-cache");
  269.  
  270. xhr.send(data);
  271.  
  272. }

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址