// ==UserScript== // @name 有道云笔记 // @name:zh-CN 有道云笔记 // @description:zh-cn ... // @namespace ... // @version 0.2 // @description 使工具架更窄,编辑器空间更大;如果你有能力欢迎 更改它,但要无偿分享; // @author 扶妹柠檬茶 // @license MIT // @match https://note.youdao.com/web/* // @require http://code.jquery.com/jquery-latest.js // @grant unsafeWindow // @grant GM_addStyle // @grant GM_getValue // @grant GM_setValue // @grant GM_deleteValue // @grant GM_listValues // @grant GM_openInTab // @grant GM_notification // @grant GM_xmlhttpRequest // @downloadURL https://update.greasyfork.icu/scripts/449774/%E6%9C%89%E9%81%93%E4%BA%91%E7%AC%94%E8%AE%B0.user.js // @updateURL https://update.greasyfork.icu/scripts/449774/%E6%9C%89%E9%81%93%E4%BA%91%E7%AC%94%E8%AE%B0.meta.js // ==/UserScript== //左下角按键类名 var copy_class="sidebar-collapse-content-item"; //左侧栏宽度 //var app_sidebar="app_sidebar"; var l_id="#flexible-left"; var app_sidebar_wMax=40; //右侧顶栏&浮动高度 var HD_id="hd-space-between"; var noteHD_flex="0 0 40px"; var hdSpace={ id:"hd-space-between", style:"flex: 0 0 40px" } //保存按钮&高度 var noteSaveBtn_id="note-save-btn"; var noteSaveBtn_top=-35; var noteSaveBtn={ id:"note-save-btn", style:"top: -35px !important;", remark:"" } //编辑区 var bulbEditor={ id:"bulb-editor", style:"top: 38px !important;height: calc(100% - 40px)!important;", remark:"" } //隐藏列表 var listLight={ id:"flexible-list-left", style:"left: 260px !important;display: none;width: 260px;", remark:"left: 0px !important;display: block;width: 260px;" } var listRight={ id:"flexible-list-right", style:"left: 0px !important;display: block;", remark:"left: 260px !important;display: block;" } //列表栏-顶栏:搜索栏 var listSearch={ class:"list-search", style:"height: 20px !important;width: 260px !important;", remark:"设定width为了,隐藏列表时,flex样式不会乱" } //列表栏-内容区:列表 var listBD={ class:"list .list-bd.topNameTag", style:"top: 50px !important;", remark:"" } //推出全屏 var eeCopy={ id:"ee_copy", style:` font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; width: 45px; height: 30px; margin-left: 4px; text-align: center; /* margin: auto; */ /* padding-bottom: 1px; */ /* vertical-align: middle; */ border: none; border: 2px solid black; border-radius: 9px; z-index: 3; position: absolute; display:none; bottom: 10px;` } var collapseFull={ class:"collapse-full-screen", style: "display: none;", remark:"隐藏退出全屏按钮" } //构建css样式 var list=[noteSaveBtn,bulbEditor,listSearch,listBD,hdSpace,eeCopy,collapseFull]; console.log(list) function concatStyle(l){ let str=""; for(let i=0;i ` var ww_copy=`
` var ee_copy=`
保存
` var cc=document.getElementsByClassName("detail-bd")[0]; var qq=document.createElement("div"); qq.innerHTML=`
推出
` '
\n 保存\n
' function closeAd() { //移除底部(两层的)按钮 $(".sidebar-footer").css("display","none"); //瘦化左侧栏 $(l_id).css("cssText","max-width: "+app_sidebar_wMax+"px;"); $(".btn-column-two")[0].click(); $("#hd-space-between").css("cssText","flex= 0 0 40px;"); } //向html添加css样式 if(1){ GM_addStyle( ` /*删除左侧栏滑杆*/ ::-webkit-scrollbar { display: none; } app-sidebar#flexible-left:after { content: ""; flex-grow: 1; } app-sidebar#flexible-left:before { flex-grow: 1; content: ""; } ` +concatStyle(list) ); //创建退出全屏按键 var button = document.createElement("button"); button.id = "ee_copy"; button.textContent = ">|<"; document.body.appendChild(button); } class listen{ constructor() { this.observer_state=0; this.observer2_state=0; //防止,侧边栏变宽:>55px:set=55px->id:flexible-right this.observer = new MutationObserver((mutationRecord, mutationObserver) =>{ if(MutationRecord.attributeName="style"){ if(document.defaultView.getComputedStyle( document.getElementById("flexible-right"),null).left.replace(/[^0-9]/ig,"")>app_sidebar_wMax ){ $(r_id).css("cssText","left:"+app_sidebar_wMax+"px"); } } }); //注册监听防止,左侧栏展开列表->#flexible-left:collapse this.observer2 = new MutationObserver((mutationRecord, mutationObserver) =>{ if(MutationRecord.attributeName="class"){ if(document.getElementById("flexible-left").getAttribute("style")!="left: "+app_sidebar_wMax+"px;"){ $(l_id).addClass("collapse"); } } }); } start_1(){ this.observer.observe(document.getElementById("flexible-right"), { attributes: true }); this.observer_state=1; } start_2(){ this.observer2.observe(document.getElementById("flexible-left"), { attributes: true }); this.observer2_state=1; } stop_1(){ this.observer.disconnect(); this.observer_state=0; } stop_2(){ this.observer2.disconnect(); this.observer2_state=0; } } (function() { 'use strict'; var listener=new listen(); if(1){ //还有"DOMSubtreeModified" document.addEventListener("DOMNodeInserted", function (event) { if(1){ $(event.target).find(".view-container").show(function(){ closeAd(); listener.start_1() listener.start_2() //listener.start_3() document.getElementsByClassName("sidebar-collapse-footer")[0].innerHTML=qq_copy+ww_copy; document.getElementById("qq_copy").onclick=()=>{ document.getElementsByClassName("btn-column-one")[0].click(); //点击全屏时显示推出按钮 $("#ee_copy").css("cssText","display: block;") }; button.onclick=()=>{ document.getElementsByClassName("collapse-full-screen")[0].click(); if(r_stable==0){ $("#"+listLight.id).css("cssText",listLight.style); $("#"+listRight.id).css("cssText",listRight.style); }else{ $("#"+listLight.id).css("cssText",listLight.remark); $("#"+listRight.id).css("cssText",listRight.remark); } $("#ee_copy").css("cssText","display: none;") }; function qq_off(){ //$('#flexible-list-left').css({"display":"none"}); //$('#flexible-list-left').css("cssText","left:0px"); $("#"+listLight.id).css("cssText",listLight.style); $("#"+listRight.id).css("cssText",listRight.style); r_stable=0; } function qq_on(){ //$('#flexible-list-left').css({"display":"block"}); //$('#flexible-list-left').css("cssText","left:250px"); $("#"+listLight.id).css("cssText",listLight.remark); $("#"+listRight.id).css("cssText",listRight.remark); r_stable=1; } document.getElementById("ww_copy").onclick=()=>{ r_stable?qq_off():qq_on(); }; }) } //console.log(event.target.class) //alert(document.getElementById("hd-space-between")) //关闭和开启笔记列表 /* $(event.target).find(".sidebar-collapse-footer").show(function(){ document.getElementsByClassName("sidebar-collapse-footer")[0].innerHTML=envar.l.qq_copy+envar.l.ww_copy; document.getElementById("qq_copy").onclick=()=>{document.getElementsByClassName("btn-column-one")[0].click();}; function qq_off(){ $('.viewport .list-detail .list').css({"display":"none"}); $('.viewport .list-detail .detail-container').css("cssText","left:0px"); envar.r.r_stable=0; } function qq_on(){ $('.viewport .list-detail .list').css({"display":"block"}); $('.viewport .list-detail .detail-container').css("cssText","left:255px"); envar.r.r_stable=1; } document.getElementById("ww_copy").onclick=()=>{ envar.r.r_stable?qq_off():qq_on(); }; }); */ //顶栏:hd-space-between#实现二 /* $(event.target).find(".hd-space-between").show(function(){ //alert("!hd-space-between:已被添加"); $("#"+HD_id).css("cssText","flex:"+noteHD_flex); }); */ //移除广告 $(event.target).find(".ad-close").show(function(){ alert("!test:已删除广告"); $("div.ad-close").click(); }); }); } })();