ST-Script

修改google背景图、去除页脚;CSDN自动阅读全文、关闭页脚登录(不可用)注册(不可用)框、Github增加顶部导航、隐藏rtd侧边栏。

安装此脚本?
作者推荐脚本

您可能也喜欢花瓣网下载

安装此脚本
  1. // ==UserScript==
  2. // @name ST-Script
  3. // @namespace https://www.saintic.com/
  4. // @version 0.5
  5. // @description 修改google背景图、去除页脚;CSDN自动阅读全文、关闭页脚登录(不可用)注册(不可用)框、Github增加顶部导航、隐藏rtd侧边栏。
  6. // @author staugur
  7. // @match *://www.google.com/*
  8. // @match *://www.google.co.*/*
  9. // @match http*://blog.csdn.net/*/article/details/*
  10. // @match *://github.com/*
  11. // @match *://*.readthedocs.io/*
  12. // @grant none
  13. // @icon https://static.saintic.com/cdn/images/favicon-64.png
  14. // @license BSD 3-Clause License
  15. // @date 2018-04-27
  16. // @modified 2019-04-21
  17. // @github https://github.com/staugur/scripts/blob/master/userscripts/ST-Script.user.js
  18. // @supportURL https://github.com/staugur/scripts/issues
  19. // ==/UserScript==
  20.  
  21. (function () {
  22. 'use strict';
  23. //配置
  24. var conf = {
  25. google: {
  26. //此项设置是否开启修改google背景图功能
  27. enable: true,
  28. //此项设置是背景图地址,当上述项为true时有效
  29. bgUrl: "https://open.saintic.com/api/bingPic/",
  30. //此项设置隐藏google首页底部页脚
  31. hiddenFooter: true
  32. },
  33. csdn: {
  34. //此项设置自动展开全文
  35. auto_read_full: true,
  36. //此项设置关闭登录(不可用)注册(不可用)弹框
  37. auto_close_loginbox: true,
  38. //此项设置关闭左侧底部广告
  39. auto_remove_asidefooter: true
  40. },
  41. github: [
  42. /*设置你自己的导航,格式是:
  43. {
  44. text: "显示名",
  45. link: "链接地址"
  46. }
  47. */
  48. ],
  49. /*
  50. 在docs列表中添加readthedocs文档的域名,另外在上面元数据添加match,例如:
  51. // @match *://www.pycryptodome.org/*
  52. docs: ["www.pycryptodome.org"]
  53.  
  54. */
  55. docs: []
  56. };
  57. //公共接口
  58. var api = {
  59. getDomain: function () {
  60. return document.domain;
  61. },
  62. getUrlRelativePath: function () {
  63. var url = document.location.toString();
  64. var arrUrl = url.split("//");
  65. var start = arrUrl[1].indexOf("/");
  66. var relUrl = arrUrl[1].substring(start); //stop省略,截取从start开始到结尾的所有字符
  67. if (relUrl.indexOf("?") != -1) {
  68. relUrl = relUrl.split("?")[0];
  69. }
  70. return relUrl;
  71. },
  72. getUrlQuery: function (key, acq) {
  73. /*
  74. 获取URL中?之后的查询参数,不包含锚部分,比如url为http://passport.saintic.com/user/message/?status=1&Action=getCount
  75. 若无查询的key,则返回整个查询参数对象,即返回{status: "1", Action: "getCount"};
  76. 若有查询的key,则返回对象值,返回值可以指定默认值acq:如key=status, 返回1;key=test返回acq
  77. */
  78. var str = location.search;
  79. var obj = {};
  80. if (str) {
  81. str = str.substring(1, str.length);
  82. // 以&分隔字符串,获得类似name=xiaoli这样的元素数组
  83. var arr = str.split("&");
  84. //var obj = new Object();
  85. // 将每一个数组元素以=分隔并赋给obj对象
  86. for (var i = 0; i < arr.length; i++) {
  87. var tmp_arr = arr[i].split("=");
  88. obj[decodeURIComponent(tmp_arr[0])] = decodeURIComponent(tmp_arr[1]);
  89. }
  90. }
  91. return key ? obj[key] || acq : obj;
  92. },
  93. isContains: function (str, substr) {
  94. /* 判断str中是否包含substr */
  95. return str.indexOf(substr) >= 0;
  96. },
  97. arrayContains: function (arr, obj) {
  98. var i = arr.length;
  99. while (i--) {
  100. if (arr[i] === obj) {
  101. return true;
  102. }
  103. }
  104. return false;
  105. }
  106. };
  107. //给Google™ 搜索页设置个背景图片、隐藏页脚
  108. if (conf.google.enable === true) {
  109. if (api.isContains(api.getDomain(), "www.google.co") && api.arrayContains(["/", "/webhp"], api.getUrlRelativePath())) {
  110. //设置body背景颜色、图片、重复性、起始位置
  111. document.body.style.backgroundColor = "inherit";
  112. document.body.style.backgroundImage = "url('" + conf.google.bgUrl + "')";
  113. document.body.style.backgroundRepeat = "no-repeat";
  114. document.body.style.backgroundPosition = "50% 50%";
  115. //隐藏页脚
  116. if (conf.google.hiddenFooter === true) {
  117. document.getElementById('footer').style.display = 'none';
  118. }
  119. document.querySelector('.sfbg').style.display='none';
  120. }
  121. }
  122. //CSDN文章详情页自动展开全文并去除阅读更多按钮
  123. if (conf.csdn.auto_read_full === true) {
  124. if (api.isContains(api.getDomain(), "blog.csdn.net")) {
  125. var btnReadmore = $("#btn-readmore");
  126. var articleBox = $("div.article_content");
  127. //先去除阅读更多部分的style(隐藏)
  128. articleBox.removeAttr("style");
  129. //再删除越多更多按钮
  130. btnReadmore.parent().remove();
  131. }
  132. }
  133. //CSDN文章详情页关闭底部登录(不可用)注册(不可用)框
  134. if (conf.csdn.auto_close_loginbox === true) {
  135. if (api.isContains(api.getDomain(), "blog.csdn.net")) {
  136. var pb = $('.pulllog-box');
  137. //隐藏显示
  138. pb[0].style.display = 'none';
  139. }
  140. }
  141. //CSDN删除asideFooter-侧栏底部,如联系我们
  142. if (conf.csdn.auto_remove_asidefooter === true) {
  143. if (api.isContains(api.getDomain(), "blog.csdn.net")) {
  144. //删除左侧栏底部
  145. $('#asideFooter').remove();
  146. }
  147. }
  148. if (conf.github.length > 0) {
  149. if (api.isContains(api.getDomain(), "github.com") === true) {
  150. //添加导航
  151. var node, nav = document.getElementsByTagName("header")[0].getElementsByTagName("nav")[0].getElementsByTagName("a");
  152. for (var i in nav) {
  153. if (nav[i].innerText === "Explore") {
  154. node = nav[i];
  155. }
  156. }
  157. if (node) {
  158. var tmpHtml = '';
  159. for (var i in conf.github) {
  160. var gh = conf.github[i];
  161. tmpHtml += '<a class="js-selected-navigation-item Header-link mr-0 mr-lg-3 py-2 py-lg-0 border-top border-lg-top-0 border-white-fade-15" href="' + gh.link + '">' + gh.text + '</a>';
  162. }
  163. if (tmpHtml) {
  164. node.insertAdjacentHTML('afterEnd', tmpHtml);
  165. }
  166. }
  167. }
  168. if (api.isContains(api.getDomain(), "readthedocs.io") || api.arrayContains(conf.docs, api.getDomain())===true) {
  169. if (api.getUrlQuery("hide")==="0") {
  170. $('nav.wy-nav-side').css('display','none');
  171. $('div.rst-versions').css('display','none');
  172. $('section.wy-nav-content-wrap').css('margin-left', '0px');
  173. $('div.wy-nav-content').css('max-width','100%');
  174. }
  175. }
  176. }
  177. })();

QingJ © 2025

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