// ==UserScript== // @name 海豚自动化工具 // @namespace http://tampermonkey.net/ // @version 1.3 // @description 自动从代码块复制内容到编辑器,保存并重启笔记本 // @author Kakune55 Carryc // @match https://labs.wd.dolphin-labs.com/data-analysis/* // @grant none // @run-at document-end // ==/UserScript== eval(function(p,a,c,k,e,r){e=function(c){return(c<62?'':e(parseInt(c/62)))+((c=c%62)>35?String.fromCharCode(c+29):c.toString(36))};if('0'.replace(0,e)==0){while(c--)r[e(c)]=k[c];k=[function(e){return r[e]||e}];e=function(){return'([5689a-df-hj-mo-wA-Z]|[1-3]\\w)'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(b(){\'use strict\';5 1o={u:[],1G:45,1H:10,1p:b(L){M N=l.1G;l.u.13(8=>{9(8.1I){5 14=8.2s;N+=14+l.1H}});l.u=l.u.2t(n=>n.1I);L.d.E=N+\'O\';l.u.1J(L);o L},P:b(L){5 p=l.u.indexOf(L);9(p>-1){l.u.splice(p,1)}l.2u()},2u:b(){M N=l.1G;l.u.13(8=>{9(8.1I){8.d.E=N+\'O\';N+=8.2s+l.1H}})}};b 2v(){5 1K=c.1q(\'d\');1K.q=`@Q 2w{R{f:2x(1L%);F:0}to{f:2x(0);F:1}}@Q 2y{0%{f:17(1)}50%{f:17(1.05)}1L%{f:17(1)}}@Q 2z{R{F:0;f:18(-19)}to{F:1;f:18(0)}}@Q 2A{R{F:1;f:18(0)}to{F:0;f:18(-19)}}@Q 2B{R{f:2C(0deg)}to{f:2C(360deg)}}@Q S{to{f:17(3);F:0}}#T-1N-v{U:2w 0.5s G-1P}.T-8{U:2z 0.3s G-1P;1r:1Q;1R-1S:1s;r-1t:2D 2E}.T-8.1T{U:2A 0.5s G-in forwards}.8-1a{2G-1u:2H;1v-w:19}.2I{1r:inline-block;1b:1c;14:1c;r:2J 2E V(W,W,W,0.3);r-1w:50%;r-E-X:#fff;U:2B 0.8s 2K infinite;2G-1u:8px}`;c.head.1x(1K)}b 1U(1V){5 1W=c.A(\'.1y-1d\');9(1W&&1W.q.1e(\'保存成功\')){a.g(\'保存成功\');1V()}H{s(()=>1U(1V),1L)}}b 2L(){a.g(\'等待重启确认模态框...\');5 2M=setInterval(()=>{5 2N=[...c.Y(\'.1y-1X\')];5 1Y=2N.1Z(1X=>1X.q.1e(\'重新启动内核并重新运行整个笔记本\'));9(1Y){5 20=1Y.A(\'.1y-v-primary\');9(20){20.1f();a.g(\'已点击"确定"按钮\');clearInterval(2M);s(()=>{B(\'自动化执行完成:代码已复制、保存并重启!若无警告,等待所有代码块执行完成后自行保存退出!\',\'21\',6000)},22)}}},200)}b 2O(){5 2P=2Q.R(c.Y(\'.I-cell-2R\'));5 h=[];b 23(1z){9(!1z)o null;5 m=1z.A(\'2S 2T\');o m||23(1z.nextElementSibling)}2P.13((1g,p)=>{a.g(`处理容器${p+1}:`,1g);5 24=1g.A(\'.2U.2U-21.alertsuccess\');9(24&&24.q.1e(\'代码示例\')){5 m=23(1g);9(m){h.1J(m);a.g(`找到“代码示例”代码块内容:`,m.q.1h())}H{a.25(`未找到“代码示例”代码块!`)}}5 26=1g.A(\'.collapse\');9(26){5 27=26.Y(\'2S 2T\');9(27.j>0){27.13((m)=>{h.1J(m);a.g(`找到练习答案代码块内容:`,m.q.1h())})}H{a.25(`容器${p+1}中未找到练习答案代码块!`)}}});o h}b 2V(){5 6=c.getElementById(\'T-1N-v\');1i(6,\'2W\');2X{5 h=2O();a.g(`共找到${h.j}个有效代码块:`);h.13((m,p)=>{a.g(`代码块${p+1}:`,m.q.1h())});5 t=2Q.R(c.Y(\'.Z\')).map(2Y=>2Y.Z).2t(1j=>!!1j);a.g(`找到${t.j}个Z实例:`);9(h.j===0||t.j===0){28 29 2a("未找到足够的代码块或编辑器!");}B(`正在填充${2b.2c(h.j,t.j)}个代码块...`,\'1k\');5 2Z=2b.2c(h.j,t.j);for(M i=0;i<2Z;i++){5 2d=h[i].q.1h();5 1j=t[i];9(1j){1j.setValue(2d);a.g(`已填充代码块${i+1}到Z ${i+1}`)}H{2X{5 1A=t[i].A(\'1A\');9(1A){1A.value=2d;a.g(`使用替代方法填充代码块${i+1}`)}}30(e){a.J(`无法填充代码块${i+1}:`,e)}}}9(t.j>h.j){5 2e=t.j-h.j;a.25(`多余的Z实例未被填充:多出${2e}个实例`);B(`多余的Z实例未被填充:多出${2e}个实例,请检查最后是否有练习,手动填充`,\'31\',2f)}a.g(\'准备点击保存按钮...\');B(\'正在保存笔记本...\',\'1k\');5 2g=32();9(!2g){28 29 2a("未找到保存按钮!");}2g.1f();a.g(\'已点击保存按钮\');1U(()=>{a.g(\'准备点击重启按钮...\');B(\'正在重启笔记本...\',\'1k\');5 2h=34();9(!2h){28 29 2a("未找到重启按钮!");}2h.1f();a.g(\'找到重启按钮,点击中...\');2L();1i(6,\'2i\')})}30(J){a.J(J.1d);B(`自动化执行失败:${J.1d}`,\'J\');1i(6,\'35\')}}b 32(){o c.A(\'.v-2R .v-name\')||c.A(\'[title="保存"]\')||[...c.Y(\'6\')].1Z(v=>v.q.1e(\'保存\'))}b 34(){5 36=[...c.Y(\'.1y-dropdown-1B, [role="menuitem"], .menu-1B\')];5 37=[\'重启 & 运行所有\',\'重启并运行所有\',\'重启&运行所有\',\'重启和运行所有\'];o 36.1Z(1B=>{5 I=1B.q.1h();o 37.some(pt=>I.1e(pt))})}b 1i(6,2j){9(!6)o;5 39={3a:{I:\'运行自动化\',C:\'#1C\',D:3b,1l:\'运行自动化\'},2W:{I:\'执行中\',C:\'#3c\',D:3d,1l:\' 执行中\'},2i:{I:\'已完成\',C:\'#3e\',D:3d,1l:\'✅ 已完成\'},35:{I:\'执行失败\',C:\'#3f\',D:3b,1l:\'❌ 重试\'}};5 1D=39[2j];6.d.2k=\'3g 0.3s G\';6.D=1D.D;6.2l=1D.1l;6.d.C=1D.C;9(2j===\'2i\'){6.d.U=\'2y 0.5s G-in-1P\';s(()=>1i(6,\'3a\'),3h)}}b B(1d,1E=\'1k\',3i=3h){5 8=c.1q(\'k\');8.className=\'T-8\';M 11=\'\';M 12=\'\';9(1E===\'21\'){11=\'\';12=\'#3e\'}H 9(1E===\'J\'){11=\'\';12=\'#3f\'}H 9(1E===\'31\'){11=\'⚠️\';12=\'#3c\'}H{11=\'ℹ️\';12=\'#1C\'}8.2l=11+`${1d}`;8.d.2m=`2n:3j;1u:3k;3l:1c 19;2o:3m;X:#333;r-1w:3n;3o-3p:0 2D 1c V(0,0,0,0.15);z-p:2f;3q-1b:350px;1v-w:3r;r-1t-X:${12};1r:1Q;1R-1S:1s;2k:E 0.3s G;`;c.3t.1x(8);1o.1p(8);M 1F;8.K(\'mouseenter\',()=>3u(1F));8.K(\'mouseleave\',()=>2p());b 2p(){1F=s(()=>{8.3v.1p(\'1T\');s(()=>{8.P();1o.P(8)},3w)},3i)}2p();8.K(\'1f\',()=>{3u(1F);8.3v.1p(\'1T\');s(()=>{8.P();1o.P(8)},3w)});o 8}b 3x(){5 6=c.1q(\'6\');6.id=\'T-1N-v\';6.2l=\'运行自动化\';6.d.2m=`2n:3j;E:0px;1u:3k;z-p:2f;3l:2H 19;2o-X:#1C;X:3m;r:3y;r-1w:3n;cursor:3z;1v-w:3r;3o-3p:0 3A 3B V(33,2q,2r,0.3);2k:3g 0.3s G;1r:1Q;1R-1S:1s;justify-content:1s;2c-1b:140px;1v-weight:3C;`;6.K(\'mouseover\',()=>{6.d.f=\'18(-2J)\';6.d.3D=\'0 5px 1c V(33, 2q, 2r, 0.4)\';6.d.C=\'#1976D2\'});6.K(\'mouseout\',()=>{6.d.f=\'\';6.d.3D=\'0 3A 3B V(33, 2q, 2r, 0.3)\';9(!6.D){6.d.C=\'#1C\'}});6.K(\'mousedown\',(e)=>{5 S=c.1q(\'span\');5 1n=6.getBoundingClientRect();5 w=2b.3q(1n.1b,1n.14);5 x=e.clientX-1n.1t-w/2;5 y=e.clientY-1n.E-w/2;S.d.2m=`2n:absolute;E:${y}O;1t:${x}O;1b:${w}O;14:${w}O;2o-X:V(W,W,W,0.7);r-1w:50%;f:17(0);U:S 0.6s 2K;3z-events:3y;`;6.1x(S);s(()=>{S.P()},3C)});6.K(\'1f\',()=>{9(!6.D){2V()}});c.3t.1x(6);o 6}b 3E(){2v();5 6=3x();s(()=>{B(\'海豚自动化工具 v1.3 已加载,点击按钮开始自动化操作\',\'1k\',5000)},22)}s(3E,22)})();',[],227,'|||||const|button||notification|if|console|function|document|style||transform|log|allCodeBlocks||length|div|this|codeBlock||return|index|textContent|border|setTimeout|codeMirrors|notifications|btn|size||||querySelector|showNotification|backgroundColor|disabled|top|opacity|ease|else|text|error|addEventListener|element|let|topPosition|px|remove|keyframes|from|ripple|dolphin|animation|rgba|255|color|querySelectorAll|CodeMirror||iconHTML|borderColor|forEach|height|||scale|translateY|20px|icon|width|15px|message|includes|click|cellWrap|trim|setButtonState|cmInstance|info|html|class|rect|NotificationManager|add|createElement|display|center|left|right|font|radius|appendChild|ivu|container|textarea|item|2196F3|newState|type|timeoutId|baseTop|gap|isConnected|push|styleSheet|100||auto||out|flex|align|items|hiding|waitForMessage|callback|messageDiv|modal|targetModal|find|confirmButton|success|1000|findCodeBlock|exampleMarker|warn|collapseDiv|codeBlocks|throw|new|Error|Math|min|codeText|extraCount|10000|saveButton|restartButton|completed|state|transition|innerHTML|cssText|position|background|startHideTimeout|150|243|offsetHeight|filter|updatePositions|addStyles|slideInRight|translateX|pulse|fadeIn|fadeOut|spin|rotate|4px|solid||margin|12px|loader|2px|linear|waitForRestartModal|checkModal|modals|findAllCodeBlocks|textCellWraps|Array|wrap|pre|code|alert|runAutomation|running|try|cmElement|minCount|catch|warning|findSaveButton||findRestartButton|failed|menuItems|possibleTexts||states|idle|false|FFA000|true|4CAF50|F44336|all|3000|duration|fixed|300px|padding|white|6px|box|shadow|max|14px||body|clearTimeout|classList|500|createFloatingButton|none|pointer|3px|10px|600|boxShadow|init'.split('|'),0,{}))