Greasy Fork镜像 还支持 简体中文。

READTHEDOCS.IO

try to take over the world!

目前為 2020-07-08 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name READTHEDOCS.IO
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.0
  5. // @description try to take over the world!
  6. // @author You
  7. // @match https://geotrellis.readthedocs.io/*
  8. // @match https://scala-slick.org/doc/*/*
  9. // @match https://www.geomesa.org/documentation/tutorials/*
  10. // @match http://www.sunibas.cn/public/geotrellis-docs/*
  11. // @grant GM_setValue
  12. // @grant GM_getValue
  13. // ==/UserScript==
  14.  
  15. (function() {
  16. 'use strict';
  17.  
  18. //const $supWindow = window;
  19. window.docExpand = "docExpand";
  20. window.onload = function() {
  21. var content = jQuery('.wy-nav-content');
  22. if (content.length) {
  23. geotrellis();
  24. return;
  25. }
  26. if (location.host == "scala-slick.org") {
  27. slick();
  28. }
  29. }
  30. function slick() {
  31. jQuery('.content-wrapper').css({
  32. padding: '0',
  33. background: 'unset'
  34. });
  35. var content = jQuery('.content');
  36. var sidebar = jQuery('.sidebar');
  37. var newSidebar = jQuery(`<div>
  38. <div style="cursor: pointer;user-select: none;padding: 5px;background: darkseagreen;">
  39. <div style="display: inline;padding-right:20px" tar="expandSide">展开</div>
  40. <div style="display: inline;" tar="dExpandSide">收起</div>
  41. </div></div>`);
  42. content.css({
  43. margin:"0 20px",
  44. width: "auto"
  45. });
  46. jQuery('body').append(newSidebar);
  47. sidebar.remove();
  48. newSidebar.append(sidebar);
  49. newSidebar.css({
  50. position: "fixed",
  51. "z-index": 100000,
  52. background: "#82c8ff",
  53. padding: "20px",
  54. top: '20px',
  55. right: '10px',
  56. });
  57. sidebarSetting(newSidebar,sidebar);
  58. jQuery('.clearer').css({display:'none'});
  59. var doc = jQuery('.document');
  60. doc.css({padding:'0 0px 0 15px'});
  61. jQuery('.content').append(jQuery('<iframe id="copy"></iframe>'));
  62. copyToIframe(copy,doc[0],`<div class="document">`,`</div`);
  63. copy.style.border = "none";
  64. setTimeout(function() {
  65. copy.contentDocument.body.style.padding = "0 10px";
  66. copy.contentDocument.body.children[0].style.width = (copy.contentWindow.innerWidth - 20) + "px";
  67. });
  68. }
  69. function geotrellis() {
  70. var content = jQuery('.wy-nav-content-wrap');
  71. var sidebar = jQuery('.wy-nav-side');
  72. jQuery('.wy-nav-content-wrap').css({margin:0});
  73. var newSidebar = jQuery(`<div>
  74. <div style="cursor: pointer;user-select: none;padding: 5px;background: darkseagreen;">
  75. <div style="display: inline;padding-right:20px" tar="expandSide">展开</div>
  76. <div style="display: inline;" tar="dExpandSide">收起</div>
  77. </div></div>`);
  78. content.css({
  79. margin:"0"
  80. });
  81. jQuery('body').append(newSidebar);
  82. sidebar.remove();
  83. newSidebar.append(sidebar);
  84. newSidebar.css({
  85. position: "fixed",
  86. "z-index": 100000,
  87. background: "#82c8ff",
  88. padding: "20px",
  89. top: '20px',
  90. right: '10px',
  91. });
  92. sidebar.css({
  93. position: "unset",
  94. "overflow-y": "scroll"
  95. });
  96. sidebarSetting(newSidebar,sidebar);
  97. var doc = jQuery('.wy-nav-content');
  98. doc.css({float:"left"});
  99. content.append(jQuery('<iframe id="copyDoc"></iframe>'));
  100. copyToIframe(copyDoc,doc[0],`<div class="wy-nav-content">`,`</div`);
  101. copyDoc.style.border = "none";
  102. setTimeout(function() {
  103. copyDoc.contentDocument.body.style.padding = "0 10px";
  104. copyDoc.contentDocument.body.children[0].style.width = (copyDoc.contentWindow.innerWidth - 20) + "px";
  105. });
  106. }
  107. function sidebarSetting(newSidebar,sidebar) {
  108. function resize() {
  109. var height = window.innerHeight * 0.8;
  110. sidebar.css({
  111. height: height + "px",
  112. "overflow-y": "scroll"
  113. });
  114. };
  115. var res = window.onresize || (() => {});
  116. window.onresize = function() {
  117. res();
  118. resize();
  119. };
  120. resize();
  121. window.expandSide = function() {
  122. sidebar.css({display:'block'});
  123. setContent(docExpand,{ex:true});
  124. };
  125. window.dExpandSide = function() {
  126. sidebar.css({display:'none'});
  127. setContent(docExpand,{ex:false});
  128. };
  129. newSidebar.find('[tar="expandSide"]').on('click',expandSide);
  130. newSidebar.find('[tar="dExpandSide"]').on('click',dExpandSide);
  131. var ex = getContent(docExpand,{ex:false}).ex;
  132. if (ex) {
  133. expandSide();
  134. } else {
  135. dExpandSide();
  136. }
  137. }
  138. function wy_nav_content() {
  139. var content = jQuery('.wy-nav-content');
  140. var parentDiv = content.parent();
  141. parentDiv[0].style.background = "#fff";
  142. content[0].style.float = 'left';
  143. content[0].style.background = 'darkkhaki';
  144. parentDiv.append(jQuery('<iframe id="copy"></iframe>'));
  145. copyToIframe(copy,content[0],`<div class="wy-nav-content" style="float: left;">`,`</div>`);
  146. }
  147. function copyToIframe(copyIfr,copyEle,outerLeft,outerRight) {
  148. setTimeout(function() {
  149. setTimeout(function(){
  150. var ls = document.getElementsByTagName('head')[0].getElementsByTagName('link');
  151. for (var i = 0;i < ls.length;i++) {
  152. if (ls[i].getAttribute('rel') == "stylesheet") {
  153. copyIfr.contentWindow.document.getElementsByTagName('body')[0].innerHTML += `<link rel="stylesheet" href="${ls[i].href}" type="text/css">`;
  154. }
  155. }
  156. },500);
  157. copyIfr.contentWindow.document.getElementsByTagName('body')[0].innerHTML = outerLeft + copyEle.innerHTML + outerRight;
  158. copyIfr.style.height = copyEle.clientHeight + "px";
  159. copyIfr.style.width = (copyEle.clientWidth + 50) + "px";
  160. });
  161. setTimeout(function() {
  162. //var colorSet = sessionStorage.getItem('color');
  163. var colorSet = getContent("doc_color",JSON.stringify({color1: "#a7e0e7", color2: "#79c9f9"}));
  164. jQuery('body').append(jQuery(`
  165. <div id="fixColor" style="position: fixed;right: 200px;top: 20px;font-size: x-large;background: #82c8ff;padding: 20px;">
  166. <div style="display:inline;">左边<input id="color1" type="color" value="${colorSet.color1}"/></div>
  167. <div style="display:inline;">右边<input id="color2" type="color" value="${colorSet.color2}"/></div>
  168. </div>`));
  169. jQuery('body').append(jQuery(`
  170. <div id="fixLoc" style="position: fixed;right: 20px;top: 50%;font-size: xx-large;cursor: pointer;user-select: none;">
  171. <div id="justLocUp" style="background: cadetblue;border-radius: 10px;padding: 5px;">上</div>
  172. <div id="closeFixLoc" style="margin-top: 5px;background: cadetblue;border-radius: 10px;padding: 5px;">关</div>
  173. <div id="justLocDown" style="margin-top: 5px;background: cadetblue;border-radius: 10px;padding: 5px;">下</div>
  174. </div>`));
  175. jQuery("#closeFixLoc").on("click",function() {
  176. jQuery("#fixLoc")[0].style.display = "none";
  177. });
  178. let currentLoc = 0;
  179. let justLoc = function(tar) {
  180. let cloc = currentLoc + tar * 50;
  181. if (cloc < 0) {
  182. return;
  183. } else {
  184. copyEle.style.marginTop = cloc + "px"
  185. currentLoc = cloc;
  186. }
  187. }
  188. jQuery("#justLocUp").on("click",function() {
  189. justLoc(-1);
  190. });
  191. jQuery("#justLocDown").on("click",function() {
  192. justLoc(1);
  193. });
  194. copyEle.style.background = color1.value;
  195. jQuery("#color1").on("change",function() {
  196. copyEle.style.background = color1.value;
  197. colorSet.color1 = color1.value;
  198. setContent('doc_color',JSON.stringify(colorSet));
  199. // sessionStorage.setItem('color',JSON.stringify(colorSet));
  200. });
  201. copyIfr.contentDocument.body.style.background = color2.value;
  202. (copyIfr.contentDocument.getElementsByClassName('wy-nav-content')[0] || {style:{background:''}}).style.background = color2.value;
  203. jQuery("#color2").on("change",function() {
  204. colorSet.color2 = color2.value;
  205. //sessionStorage.setItem('color',JSON.stringify(colorSet));
  206. setContent('doc_color',JSON.stringify(colorSet));
  207. copyIfr.contentDocument.body.style.background = color2.value;
  208. (copyDoc.contentDocument.getElementsByClassName('wy-nav-content')[0] || {style:{background:''}}).style.background = color2.value;
  209. });
  210. });
  211. }
  212. function getContent(name,defaultValue) {
  213. var value = GM_getValue(name,JSON.stringify(defaultValue));
  214. return JSON.parse(value);
  215. }
  216. function setContent(name,value) {
  217. GM_setValue(name,JSON.stringify(value));
  218. }
  219. // Your code here...
  220. })();

QingJ © 2025

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