有道云笔记多合一精简网页

去除页面周边的多余 信息,使您在有道云笔记中可以直接阅读到清爽的正文效果

  1. // ==UserScript==
  2. // @name 有道云笔记多合一精简网页
  3. // @icon https://note.youdao.com/favicon.ico
  4. // @version 1.0.6
  5. // @description 去除页面周边的多余 信息,使您在有道云笔记中可以直接阅读到清爽的正文效果
  6. // @author 王嘉乐
  7. // @include *
  8. // @require http://code.jquery.com/jquery-latest.js
  9. // @grant GM_registerMenuCommand
  10. // @grant GM_getResourceText
  11. // @resource YNoteClipper https://note.youdao.com/yws/YNoteClipper.js?_=1596113955041
  12. // @run-at document-start
  13. // @license MIT
  14. // @namespace https://gf.qytechs.cn/users/1213222
  15. // ==/UserScript==
  16. //左下角按键类名
  17. var copy_class="sidebar-collapse-content-item";
  18.  
  19. //左侧栏宽度
  20. //var app_sidebar="app_sidebar";
  21. var l_id="#flexible-left";
  22. var app_sidebar_wMax=40;
  23.  
  24. //右侧顶栏&浮动高度
  25. var HD_id="hd-space-between";
  26. var noteHD_flex="0 0 40px";
  27. var hdSpace={
  28. id:"hd-space-between",
  29. style:"flex: 0 0 40px"
  30. }
  31. //保存按钮&高度
  32. var noteSaveBtn_id="note-save-btn";
  33. var noteSaveBtn_top=-35;
  34. var noteSaveBtn={
  35. id:"note-save-btn",
  36. style:"top: -35px !important;",
  37. remark:""
  38. }
  39. //编辑区
  40. var bulbEditor={
  41. id:"bulb-editor",
  42. style:"top: 38px !important;height: calc(100% - 40px)!important;",
  43. remark:""
  44. }
  45. //隐藏列表
  46. var listLight={
  47. id:"flexible-list-left",
  48. style:"left: 260px !important;display: none;width: 260px;",
  49. remark:"left: 0px !important;display: block;width: 260px;"
  50.  
  51. }
  52. var listRight={
  53. id:"flexible-list-right",
  54. style:"left: 0px !important;display: block;",
  55. remark:"left: 260px !important;display: block;"
  56. }
  57. //列表栏-顶栏:搜索栏
  58. var listSearch={
  59. class:"list-search",
  60. style:"height: 20px !important;width: 260px !important;",
  61. remark:"设定width为了,隐藏列表时,flex样式不会乱"
  62. }
  63. //列表栏-内容区:列表
  64. var listBD={
  65. class:"list .list-bd.topNameTag",
  66. style:"top: 50px !important;",
  67. remark:""
  68. }
  69. //推出全屏
  70. var eeCopy={
  71. id:"ee_copy",
  72. style:` font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  73. width: 45px;
  74. height: 30px;
  75. margin-left: 4px;
  76. text-align: center;
  77. /* margin: auto; */
  78. /* padding-bottom: 1px; */
  79. /* vertical-align: middle; */
  80. border: none;
  81. border: 2px solid black;
  82. border-radius: 9px;
  83. z-index: 3;
  84. position: absolute;
  85. display:none;
  86. bottom: 10px;`
  87. }
  88. var collapseFull={
  89. class:"collapse-full-screen",
  90. style: "display: none;",
  91. remark:"隐藏退出全屏按钮"
  92. }
  93. //构建css样式
  94. var list=[noteSaveBtn,bulbEditor,listSearch,listBD,hdSpace,eeCopy,collapseFull];
  95. console.log(list)
  96. function concatStyle(l){
  97. let str="";
  98. for(let i=0;i<l.length;i++){
  99. if(l[i].id){
  100. str=str+"#"+l[i].id;
  101. }else if(l[i].class){
  102. str=str+"."+l[i].class;
  103. }
  104. if(l[i].style){
  105. str=str+"{"+l[i].style+"} "
  106. }
  107. }
  108. return str;;
  109. }
  110. //自定义按钮组
  111. var r_stable=1
  112. var r_id="#flexible-right"
  113. var qq_copy=`<div class=`+copy_class+` id="qq_copy">
  114. <i class="icon-column-one" svg-icon="" svgname="view_1"><svg style="display: inline-block; width: 100%; height: 100%" role="img" class="">
  115. <use xlink:href="#view_1"></use>
  116. </svg></i>
  117. </div>`
  118. var ww_copy=`<div class=`+copy_class+` id="ww_copy">
  119. <i class="icon-column-two" svg-icon="" svgname="view_2"><svg style="display: inline-block; width: 100%; height: 100%" role="img" class="">
  120. <use xlink:href="#view_2"></use>
  121. </svg></i>
  122. </div>`
  123. var ee_copy=`<div class="note-tip editor-inside" id="ee_copy">
  124. 保存
  125. </div>`
  126. var cc=document.getElementsByClassName("detail-bd")[0];
  127. var qq=document.createElement("div");
  128. qq.innerHTML=`<div class="note-tip editor-inside" id="ee_copy">
  129. 推出
  130. </div>`
  131. '<div class="note-tip editor-inside" id="ee_copy">\n 保存\n </div>'
  132. function closeAd() {
  133. //移除底部(两层的)按钮
  134. $(".sidebar-footer").css("display","none");
  135. //瘦化左侧栏
  136. $(l_id).css("cssText","max-width: "+app_sidebar_wMax+"px;");
  137. $(".btn-column-two")[0].click();
  138. $("#hd-space-between").css("cssText","flex= 0 0 40px;");
  139.  
  140. }
  141. //向html添加css样式
  142. if(1){
  143. GM_addStyle(
  144. `
  145. /*删除左侧栏滑杆*/
  146. ::-webkit-scrollbar {
  147. display: none;
  148. }
  149. app-sidebar#flexible-left:after {
  150. content: "";
  151. flex-grow: 1;
  152. }
  153. app-sidebar#flexible-left:before {
  154. flex-grow: 1;
  155. content: "";
  156. }
  157. `
  158. +concatStyle(list)
  159. );
  160. //创建退出全屏按键
  161. var button = document.createElement("button");
  162. button.id = "ee_copy";
  163. button.textContent = ">|<";
  164. document.body.appendChild(button);
  165. }
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173. class listen{
  174.  
  175. constructor() {
  176.  
  177. this.observer_state=0;
  178. this.observer2_state=0;
  179.  
  180. //防止,侧边栏变宽:>55px:set=55px->id:flexible-right
  181. this.observer = new MutationObserver((mutationRecord, mutationObserver) =>{
  182. if(MutationRecord.attributeName="style"){
  183. if(document.defaultView.getComputedStyle(
  184. document.getElementById("flexible-right"),null).left.replace(/[^0-9]/ig,"")>app_sidebar_wMax
  185. ){
  186. $(r_id).css("cssText","left:"+app_sidebar_wMax+"px");
  187. }
  188. }
  189. });
  190.  
  191. //注册(不可用)监听防止,左侧栏展开列表->#flexible-left:collapse
  192. this.observer2 = new MutationObserver((mutationRecord, mutationObserver) =>{
  193. if(MutationRecord.attributeName="class"){
  194. if(document.getElementById("flexible-left").getAttribute("style")!="left: "+app_sidebar_wMax+"px;"){
  195. $(l_id).addClass("collapse");
  196. }
  197. }
  198. });
  199.  
  200.  
  201.  
  202. }
  203.  
  204. start_1(){
  205. this.observer.observe(document.getElementById("flexible-right"), { attributes: true });
  206. this.observer_state=1;
  207. }
  208. start_2(){
  209. this.observer2.observe(document.getElementById("flexible-left"), { attributes: true });
  210. this.observer2_state=1;
  211. }
  212. stop_1(){
  213. this.observer.disconnect();
  214. this.observer_state=0;
  215. }
  216. stop_2(){
  217. this.observer2.disconnect();
  218. this.observer2_state=0;
  219. }
  220. }
  221.  
  222. (function() {
  223. 'use strict';
  224. //去网页广告
  225. window.onload=function (){
  226. var sidebarFt = document.getElementsByClassName('sidebar-ft')[0];
  227. sidebarFt.parentNode.removeChild(sidebarFt);
  228.  
  229. document.getElementsByClassName('sidebar-content')[0].style.bottom = 0;
  230. };
  231. //重构页面
  232. window.setTimeout(e => {
  233. let target = document.querySelector('.main-container')
  234. let top = document.querySelector('.top-banner')
  235. top.style.zIndex = 0
  236. target.style.top = 0
  237. target.style.translation = 'all 0.5s'
  238. }, 100)
  239. //注册(不可用)油猴菜单
  240. GM_registerMenuCommand('一键收藏', function () {
  241. var ydNoteWebClipperElem = document.getElementById('ydNoteWebClipper');
  242. if(document.getElementById('ydNoteWebClipper')) {
  243. document.body.removeChild(ydNoteWebClipperElem);
  244. }
  245. try {
  246. var YNoteClipper = GM_getResourceText('YNoteClipper');
  247. if(YNoteClipper) {
  248. new Function(YNoteClipper)();
  249. } else {
  250. var a = document.createElement('div');
  251. a.style.cssText = 'position: absolute;top: 10px;right: 30px;padding: 5px;border-radius: 5px;box-shadow: rgb(92, 184, 229) 0px 0px 2px; -webkit-box-shadow: rgb(92, 184, 229) 0px 0px 2px;background-color: rgba(92, 184, 229, 0.498039) !important;z-index: 999999;';
  252. a.innerHTML = 'Load script error!';
  253. document.body.appendChild(a);
  254. a.onclick = function() {
  255. a.style.display = 'none';
  256. };
  257. setTimeout(function() {
  258. a.click();
  259. }, 8e3);
  260. }
  261. } catch(b) {
  262. alert('该扩展暂不支持当前的浏览器或不支持收藏该类型https类网站');
  263. console.error(b);
  264. }
  265. });
  266. //重构页面
  267. var listener=new listen();
  268.  
  269. if(1){
  270.  
  271. //还有"DOMSubtreeModified"
  272. document.addEventListener("DOMNodeInserted", function (event) {
  273. if(1){
  274. $(event.target).find(".view-container").show(function(){
  275. closeAd();
  276. listener.start_1()
  277. listener.start_2()
  278. //listener.start_3()
  279. document.getElementsByClassName("sidebar-collapse-footer")[0].innerHTML=qq_copy+ww_copy;
  280.  
  281. document.getElementById("qq_copy").onclick=()=>{
  282. document.getElementsByClassName("btn-column-one")[0].click();
  283. //点击全屏时显示推出按钮
  284. $("#ee_copy").css("cssText","display: block;")
  285. };
  286.  
  287.  
  288.  
  289. button.onclick=()=>{
  290. document.getElementsByClassName("collapse-full-screen")[0].click();
  291. if(r_stable==0){
  292. $("#"+listLight.id).css("cssText",listLight.style);
  293. $("#"+listRight.id).css("cssText",listRight.style);
  294. }else{
  295. $("#"+listLight.id).css("cssText",listLight.remark);
  296. $("#"+listRight.id).css("cssText",listRight.remark);
  297. }
  298. $("#ee_copy").css("cssText","display: none;")
  299. };
  300.  
  301.  
  302. function qq_off(){
  303. //$('#flexible-list-left').css({"display":"none"});
  304. //$('#flexible-list-left').css("cssText","left:0px");
  305. $("#"+listLight.id).css("cssText",listLight.style);
  306. $("#"+listRight.id).css("cssText",listRight.style);
  307. r_stable=0;
  308. }
  309. function qq_on(){
  310. //$('#flexible-list-left').css({"display":"block"});
  311. //$('#flexible-list-left').css("cssText","left:250px");
  312. $("#"+listLight.id).css("cssText",listLight.remark);
  313. $("#"+listRight.id).css("cssText",listRight.remark);
  314. r_stable=1;
  315. }
  316. document.getElementById("ww_copy").onclick=()=>{
  317. r_stable?qq_off():qq_on();
  318. };
  319.  
  320. })
  321. }
  322.  
  323. //console.log(event.target.class)
  324.  
  325. //alert(document.getElementById("hd-space-between"))
  326. //关闭和开启笔记列表
  327. /*
  328. $(event.target).find(".sidebar-collapse-footer").show(function(){
  329. document.getElementsByClassName("sidebar-collapse-footer")[0].innerHTML=envar.l.qq_copy+envar.l.ww_copy;
  330. document.getElementById("qq_copy").onclick=()=>{document.getElementsByClassName("btn-column-one")[0].click();};
  331. function qq_off(){
  332. $('.viewport .list-detail .list').css({"display":"none"});
  333. $('.viewport .list-detail .detail-container').css("cssText","left:0px");
  334. envar.r.r_stable=0;
  335. }
  336. function qq_on(){
  337. $('.viewport .list-detail .list').css({"display":"block"});
  338. $('.viewport .list-detail .detail-container').css("cssText","left:255px");
  339. envar.r.r_stable=1;
  340. }
  341. document.getElementById("ww_copy").onclick=()=>{
  342. envar.r.r_stable?qq_off():qq_on();
  343. };
  344. });
  345. */
  346.  
  347. //顶栏:hd-space-between#实现二
  348. /*
  349. $(event.target).find(".hd-space-between").show(function(){
  350. //alert("!hd-space-between:已被添加");
  351. $("#"+HD_id).css("cssText","flex:"+noteHD_flex);
  352. });
  353. */
  354.  
  355. //移除广告
  356. $(event.target).find(".ad-close").show(function(){
  357. alert("!test:已删除广告");
  358. $("div.ad-close").click();
  359. });
  360. });
  361.  
  362. }
  363. })();

QingJ © 2025

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