// ==UserScript== // @name 海豚自动化工具 // @namespace http://tampermonkey.net/ // @version 1.2 // @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-rt-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}('(f(){\'use strict\';8 1g={p:[],1D:70,1E:10,1h:f(K){L M=h.1D;h.p.1i(6=>{9(6.1F){8 11=6.2g;M+=11+h.1E}});h.p=h.p.filter(n=>n.1F);K.c.B=M+\'N\';h.p.push(K);O K},P:f(K){8 j=h.p.indexOf(K);9(j>-1){h.p.splice(j,1)}h.2h()},2h:f(){L M=h.1D;h.p.1i(6=>{9(6.1F){6.c.B=M+\'N\';M+=6.2g+h.1E}})}};f 2i(){8 1G=a.1j(\'c\');1G.C=`@Q 2j{1H{d:2k(1k%);D:0}to{d:2k(0);D:1}}@Q 2l{0%{d:12(1)}50%{d:12(1.05)}1k%{d:12(1)}}@Q 2m{1H{D:0;d:13(-R)}to{D:1;d:13(0)}}@Q 2n{1H{D:1;d:13(0)}to{D:0;d:13(-R)}}@Q 2o{0%{d:2p(0deg)}1k%{d:2p(360deg)}}@Q S{to{d:12(3);D:0}}#T-1J-q{U:2j 0.5s E-1L}.T-6{U:2m 0.3s E-1L;1m:1M;1N-1O:1n;l-1o:2q 2r}.T-6.1P{U:2n 0.5s E-in forwards}.6-1p{2t-1q:2u;1r-r:R}.2v{1m:inline-block;14:16;11:16;l:2w 2r V(W,W,W,0.3);l-1s:50%;l-B-X:#fff;U:2o 0.8s 2x infinite;2t-1q:8px}`;a.head.1t(1G)}f 1Q(1R){8 1S=a.17(\'.1u-1T\');9(1S&&1S.C.1v(\'保存成功\')){b.g(\'保存成功\');1R()}F{m(()=>1Q(1R),1k)}}f 2y(){b.g(\'等待重启确认模态框...\');8 2z=setInterval(()=>{8 2A=[...a.t(\'.1u-1U\')];8 1V=2A.1W(1U=>1U.C.1v(\'重新启动内核并重新运行整个笔记本\'));9(1V){8 1X=1V.17(\'.1u-q-primary\');9(1X){1X.18();b.g(\'已点击"确定"按钮\');clearInterval(2z);m(()=>{o(\'自动化执行完成:代码已复制、保存并重启\',\'2B\')},1Y)}}},200)}f 2C(19){O 19.innerText||[...19.t(\'1w\')].reduce((u,1w)=>u+1w.C,\'\')}f o(1T,1Z=\'1a\'){8 6=a.1j(\'k\');6.className=\'T-6\';L 1b=\'\';L 1c=\'\';9(1Z===\'2B\'){1b=\'\';1c=\'#2D\'}F 9(1Z===\'v\'){1b=\'\';1c=\'#2E\'}F{1b=\'ℹ️\';1c=\'#1x\'}6.20=1b+`${1T}`;6.c.21=`22:2F;1q:2G;2H:16 R;23:2I;X:#333;l-1s:2J;2K-2L:0 2q 16 V(0,0,0,0.15);z-j:2M;2N-14:350px;1r-r:2O;l-1o-X:${1c};1m:1M;1N-1O:1n;24:B 0.3s E;`;a.2P.1t(6);1g.1h(6);L 1y;6.G(\'mouseenter\',()=>{2Q(1y)});6.G(\'mouseleave\',()=>{25()});f 25(){1y=m(()=>{6.2R.1h(\'1P\');m(()=>{6.P();1g.P(6)},2S)},2T)}25();6.G(\'18\',()=>{2Q(1y);6.2R.1h(\'1P\');m(()=>{6.P();1g.P(6)},2S)});O 6}f H(5,26){9(!5)O;8 2U={2V:{u:\'运行自动化\',w:\'#1x\',A:2W,1d:\'运行自动化\'},2X:{u:\'执行中\',w:\'#FFA000\',A:2Y,1d:\' 执行中\'},27:{u:\'已完成\',w:\'#2D\',A:2Y,1d:\'✅ 已完成\'},1z:{u:\'执行失败\',w:\'#2E\',A:2W,1d:\'❌ 重试\'}};8 1A=2U[26];5.c.24=\'2Z 0.3s E\';5.A=1A.A;5.20=1A.1d;5.c.w=1A.w;9(26===\'27\'){5.c.U=\'2l 0.5s E-in-1L\';m(()=>H(5,\'2V\'),2T)}}f 30(){8 5=a.getElementById(\'T-1J-q\');H(5,\'2X\');L 1e=a.t(\'28 > 29.cm-s-ipython[Y*="31-"]\')||a.t(\'28 > 29[Y*="31-"]\')||a.t(\'28 > 29\');b.g(`找到${1e.I}个代码块`);8 J=a.t(\'.32\');b.g(`找到${J.I}个编辑器`);9(1e.I>0&&J.I>0){o(`正在填充${34.35(1e.I,J.I)}个代码块...`,\'1a\');1e.1i((19,j)=>{9(jq.C.1v(\'保存\'));9(2b){2b.18();b.g(\'已点击保存按钮\');1Q(()=>{b.g(\'准备点击重启按钮...\');o(\'正在重启笔记本...\',\'1a\');8 2c=[...a.t(\'.1u-dropdown-Z, [role="menuitem"], .menu-Z\')];8 36=[\'重启 & 运行所有\',\'重启并运行所有\',\'重启&运行所有\',\'重启和运行所有\'];8 2d=2c.1W(Z=>{8 u=Z.C.37();O 36.some(pt=>u.1v(pt))});9(2d){b.g(\'找到重启按钮,点击中...\');2d.18();2y();H(5,\'27\')}F{b.v(\'未找到重启按钮!\');b.g(\'可用菜单项:\');2c.1i((Z,i)=>b.g(`${i+1}."${Z.C.37()}"`));o(\'自动化执行失败:未找到重启按钮!\',\'v\');H(5,\'1z\')}})}F{b.v(\'未找到保存按钮!\');o(\'自动化执行失败:未找到保存按钮!\',\'v\');H(5,\'1z\')}}F{b.v("未找到足够的代码块或编辑器!");o(\'自动化执行失败:未找到足够的代码块或编辑器!\',\'v\');H(5,\'1z\')}}f 39(){8 5=a.1j(\'5\');5.id=\'T-1J-q\';5.20=\'运行自动化\';5.c.21=`22:2F;B:R;1q:2G;z-j:2M;2H:2u R;23-X:#1x;X:2I;l:3a;l-1s:2J;cursor:3b;1r-r:2O;2K-2L:0 3c 3d V(33,2e,2f,0.3);24:2Z 0.3s E;1m:1M;1N-1O:1n;justify-content:1n;35-14:140px;1r-weight:3e;`;5.G(\'mouseover\',()=>{5.c.d=\'13(-2w)\';5.c.3f=\'0 5px 16 V(33, 2e, 2f, 0.4)\';5.c.w=\'#1976D2\'});5.G(\'mouseout\',()=>{5.c.d=\'\';5.c.3f=\'0 3c 3d V(33, 2e, 2f, 0.3)\';9(!5.A){5.c.w=\'#1x\'}});5.G(\'mousedown\',(e)=>{8 S=a.1j(\'1w\');8 1f=5.getBoundingClientRect();8 r=34.2N(1f.14,1f.11);8 x=e.clientX-1f.1o-r/2;8 y=e.clientY-1f.B-r/2;S.c.21=`22:absolute;B:${y}N;1o:${x}N;14:${r}N;11:${r}N;23-X:V(W,W,W,0.7);l-1s:50%;d:12(0);U:S 0.6s 2x;3b-events:3a;`;5.1t(S);m(()=>{S.P()},3e)});5.G(\'18\',()=>{9(!5.A){30()}});a.2P.1t(5);O 5}f 3g(){2i();8 5=39();m(()=>{o(\'海豚自动化工具已加载,点击按钮开始自动化操作\',\'1a\')},1Y)}m(3g,1Y)})();',[],203,'|||||button|notification||const|if|document|console|style|transform||function|log|this||index|div|border|setTimeout||showNotification|notifications|btn|size||querySelectorAll|text|error|backgroundColor||||disabled|top|textContent|opacity|ease|else|addEventListener|setButtonState|length|codeMirrors|element|let|topPosition|px|return|remove|keyframes|20px|ripple|dolphin|animation|rgba|255|color|class|item||height|scale|translateY|width||15px|querySelector|click|codeBlock|info|iconHTML|borderColor|html|codeBlocks|rect|NotificationManager|add|forEach|createElement|100||display|center|left|icon|right|font|radius|appendChild|ivu|includes|span|2196F3|timeoutId|failed|newState||textarea|baseTop|gap|isConnected|styleSheet|from||auto||out|flex|align|items|hiding|waitForMessage|callback|messageDiv|message|modal|targetModal|find|confirmButton|1000|type|innerHTML|cssText|position|background|transition|startHideTimeout|state|completed|pre|code|codeText|saveButton|menuItems|restartButton|150|243|offsetHeight|updatePositions|addStyles|slideInRight|translateX|pulse|fadeIn|fadeOut|spin|rotate|4px|solid||margin|12px|loader|2px|linear|waitForRestartModal|checkModal|modals|success|extractCodeText|4CAF50|F44336|fixed|300px|padding|white|6px|box|shadow|10000|max|14px|body|clearTimeout|classList|500|3000|states|idle|false|running|true|all|runAutomation|language|CodeMirror||Math|min|possibleTexts|trim||createFloatingButton|none|pointer|3px|10px|600|boxShadow|init'.split('|'),0,{}))