CSDN 净化

去除CSDN多余的广告侧边栏信息,阅读全文自动展开

  1. // ==UserScript==
  2. // @name CSDN 净化
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.4
  5. // @description 去除CSDN多余的广告侧边栏信息,阅读全文自动展开
  6. // @author 贺墨于
  7. // @match *://*.csdn.net/*
  8. // @grant none
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12.  
  13. var CSDNPluify = {
  14. gList: [],
  15. $(obj){
  16. var elem = document.querySelectorAll(obj)
  17. elem.css = function(propertyName, value){
  18. for(var i = 0, len = elem.length; i < len; i++){
  19. elem[i].style[propertyName] = value
  20. }
  21. }
  22. elem.cssText = function(value){
  23. for(var i = 0, len = elem.length; i < len; i++){
  24. elem[i].style.cssText = value
  25. }
  26. }
  27. elem.remove = function(){
  28. for(var i = 0, len = elem.length; i < len; i++){
  29. elem[i].remove()
  30. }
  31. }
  32. return elem
  33. },
  34. fitContent(){
  35. this.$('.hide-article-box').remove();
  36. this.$('#mainBox').css('width','100%');
  37. this.$('#mainBox main').cssText('width:100% !important');
  38. this.$('#article_content').css('height','auto');
  39. setTimeout(function(){
  40. this.$('.tool-box.vertical').css('right', '33px');
  41. this.$('div.csdn-side-toolbar').css('right', '33px');
  42. }, 1000);
  43. },
  44. execHidden(){
  45. for(var i = 0; i < this.gList.length; i++){
  46. this.hidden(this.gList[i]);
  47. }
  48. },
  49. push(content){
  50. this.gList.push(content);
  51. },
  52. log(msg){
  53. console.log(msg);
  54. },
  55. hidden(obj){
  56. if(typeof(obj)=== 'string'){
  57. obj = this.$(obj);
  58. }
  59. //obj.remove()
  60. obj.css('display', 'none')
  61. },
  62. init(){
  63. this.push('.aside-box');
  64. this.push('.recommend-box');
  65. this.push('.template-box');
  66. this.push('.recommend-right');
  67. this.execHidden();
  68. this.fitContent();
  69. }
  70. }
  71.  
  72. CSDNPluify.init()