Pull to refresh

Скриптлеты для Web-разработчика + подарок

Reading time 41 min
Views 6.1K
Для начала. Что же такое скриптлет?

Скриптлет — яваскрипт, помещеный в закладку и выполняемый на открытой странице при нажатии на ту самую закладку.

С помощбю скриптлетов можно видоизменять страницу, редактировать или отлаживать дизайн, искать ошибки в своих скриптах и еще очень много чего…

Заинтересовал? =)

Начнем со скриптлетов для Web-разработчика

К сожалению Хабр не дает вставить скриптлеты как ссылки… Поэтому придется все приводить как есть… В теге code… =(
В связи с этим сразу прошу простить меня за «кровавое месиво» кода на странце. Я оформлял все аккуратненько в ссылочки, но хабр порезал все.

Обзор гигантов



XRAY

( http://westciv.com/xray/ )



Это очень удобное средство для проверки своих догадок. Именно так. Вы просто запускаете этот скриптлет, и после загрузки JS вы видите вот такое окошко. И Вам надо всего лишь выбрать любой элемент страницы для получения детальной информации о нем.

Скриптлет: javascript:function%20loadScript(scriptURL)%20{%20var%20scriptElem%20=%20document.createElement('SCRIPT');%20scriptElem.setAttribute('language',%20'JavaScript');%20scriptElem.setAttribute('src',%20scriptURL);%20document.body.appendChild(scriptElem);}loadScript('http://westciv.com/xray/thexray.js');

Fire Bug Lite

( http://getfirebug.com/lite.html )



FireBug в особом представлении не нуждается. Это очень знаменитый и всем полюбившейся плагин для FireFox. Но теперь он доступен в версии Lite для всех браузеров!

Скриптлет: javascript:var%20firebug=document.createElement('script');firebug.setAttribute('src','http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js');document.body.appendChild(firebug);(function(){if(window.pi&&window.firebug){firebug.init();}else{setTimeout(arguments.callee);}})();void(firebug);

А теперь отойдем от таких монстром как XRAY и FireBug Lite. Обзор «маленьких» скриптлетов.



Просмотр паролей (заменить звездочки на буковки)

javascript:(function(){var%20s,F,j,f,i;%20s%20=%20%22%22;%20F%20=%20document.forms;%20for(j=0;%20j%3CF.length;%20++j)%20{%20f%20=%20F[j];%20for%20(i=0;%20i%3Cf.length;%20++i)%20{%20if%20(f[i].type.toLowerCase()%20==%20%22password%22)%20s%20+=%20f[i].value%20+%20%22\n%22;%20}%20}%20if%20(s)%20alert(%22Passwords%20in%20forms%20on%20this%20page:\n\n%22%20+%20s);%20else%20alert(%22There%20are%20no%20passwords%20in%20forms%20on%20this%20page.%22);})();

Изображения на странице

javascript:(function(){function%20I(u){var%20t=u.split('.'),e=t[t.length-1].toLowerCase();return%20{gif:1,jpg:1,jpeg:1,png:1,mng:1}[e]}function%20hE(s){return%20s.replace(/&/g,'&').replace(/%3E/g,'>').replace(/%3C/g,'<').replace(/%22/g,'"');}var%20q,h,i,z=open().document;z.write('%3Cp%3EImages%20linked%20to%20by%20'+hE(location.href)+':%3C/p%3E%3Chr%3E');for(i=0;q=document.links[i];++i){h=q.href;if(h&&I(h))z.write('%3Cp%3E'+q.innerHTML+'%20('+hE(h)+')%3Cbr%3E%3Cimg%20src=%22'+hE(h)+'%22%3E');}z.close();})()

Найти все ссылки на странице

javascript:(function(){var%20x,n,nD,z,i;%20function%20htmlEscape(s){s=s.replace(/&/g,'&');s=s.replace(/%3E/g,'>');s=s.replace(/%3C/g,'<');return%20s;}%20function%20attrQuoteEscape(s){s=s.replace(/&/g,'&');%20s=s.replace(/%22/g,%20'"');return%20s;}%20x=prompt(%22show%20links%20with%20this%20word/phrase%20in%20link%20text%20or%20target%20url%20(leave%20blank%20to%20list%20all%20links):%22,%20%22%22);%20n=0;%20if(x!=null)%20{%20x=x.toLowerCase();%20nD%20=%20window.open().document;%20nD.writeln('%3Chtml%3E%3Chead%3E%3Ctitle%3ELinks%20containing%20%22'+htmlEscape(x)+'%22%3C/title%3E%3Cbase%20target=%22_blank%22%3E%3C/head%3E%3Cbody%3E');%20nD.writeln('Links%20on%20%3Ca%20href=%22'+attrQuoteEscape(location.href)+'%22%3E'+htmlEscape(location.href)+'%3C/a%3E%3Cbr%3E%20with%20link%20text%20or%20target%20url%20containing%20"'%20+%20htmlEscape(x)%20+%20'"%3Cbr%3E%3Chr%3E');%20z%20=%20document.links;%20for%20(i%20=%200;%20i%20%3C%20z.length;%20++i)%20{%20if%20((z[i].innerHTML%20&&%20z[i].innerHTML.toLowerCase().indexOf(x)%20!=%20-1)%20||%20z[i].href.toLowerCase().indexOf(x)%20!=%20-1%20)%20{%20nD.writeln(++n%20+%20'.%20%3Ca%20href=%22'%20+%20attrQuoteEscape(z[i].href)%20+%20'%22%3E'%20+%20(z[i].innerHTML%20||%20htmlEscape(z[i].href))%20+%20'%3C/a%3E%3Cbr%3E');%20}%20}%20nD.writeln('%3Chr%3E%3C/body%3E%3C/html%3E');%20nD.close();%20}%20})();

Поиск с использованием регулярных выражений

javascript:(function(){var%20count=0,%20text,%20regexp;text=prompt(%22Search%20regexp:%22,%20%22%22);if(text==null%20||%20text.length==0)return;try{regexp=new%20RegExp(%22(%22%20+%20text%20+%22)%22,%20%22i%22);}catch(er){alert(%22Unable%20to%20create%20regular%20expression%20using%20text%20'%22+text+%22'.\n\n%22+er);return;}function%20searchWithinNode(node,%20re){var%20pos,%20skip,%20spannode,%20middlebit,%20endbit,%20middleclone;skip=0;if(%20node.nodeType==3%20){pos=node.data.search(re);if(pos%3E=0){spannode=document.createElement(%22SPAN%22);spannode.style.backgroundColor=%22yellow%22;middlebit=node.splitText(pos);endbit=middlebit.splitText(RegExp.$1.length);middleclone=middlebit.cloneNode(true);spannode.appendChild(middleclone);middlebit.parentNode.replaceChild(spannode,middlebit);++count;skip=1;}}else%20if(%20node.nodeType==1%20&&%20node.childNodes%20&&%20node.tagName.toUpperCase()!=%22SCRIPT%22%20&&%20node.tagName.toUpperCase!=%22STYLE%22){for%20(var%20child=0;%20child%20%3C%20node.childNodes.length;%20++child){child=child+searchWithinNode(node.childNodes[child],%20re);}}return%20skip;}window.status=%22Searching%20for%20%22+regexp+%22...%22;searchWithinNode(document.body,%20regexp);window.status=%22Found%20%22+count+%22%20match%22+(count==1?%22%22:%22es%22)+%22%20for%20%22+regexp+%22.%22;})();

Перевести ненумерованые спики в нумерованые

javascript:(function(){var%20i,p,L,d,j,n;%20for(i=0;%20p=document.getElementsByTagName(%22pre%22)[i];%20++i)%20{%20L=p.innerHTML.split(%22\r\n%22);%20d=%22%22+L.length;%20for(j=0;j%3CL.length;++j)%20{%20n%20=%20%22%22+(j+1)+%22.%20%22;%20while(n.length%3Cd.length+2)%20n=%220%22+n;%20L[j]%20=%20n%20+%20L[j];%20}%20p.innerHTML=L.join(%22%3Cbr%3E%22);/*join%20with%20br%20for%20ie*/%20}%20})()

Открыть JS шелл (окно отладки)

javascript:with(window.open(%22%22,%22_blank%22,%22width=%22+screen.width*.6+%22,left=%22+screen.width*.35+%22,height=%22+screen.height*.9+%22,resizable,scrollbars=yes%22)){document.write(%22%3C!DOCTYPE%20HTML%20PUBLIC%20\%22-//W3C//DTD%20HTML%204.01//EN\%22%20\%22http://www.w3.org/TR/html4/strict.dtd\%22%3E\n\n%3Chtml%20onclick=\%22keepFocusInTextbox(event)\%22%3E\n%3Chead%3E\n%3Cmeta%20http-equiv=\%22Content-Type\%22%20content=\%22text/html;%20charset=iso-8859-1\%22%3E\n%3Ctitle%3EJavaScript%20Shell%201.4%3C/title%3E\n\n%3Cscript%20type=\%22text/javascript\%22%3E\nvar%20\nhistList%20=%20[\%22\%22],%20\nhistPos%20=%200,%20\n_scope%20=%20{},%20\n_win,%20//%20a%20top-level%20context\nquestion,\n_in,\n_out,\ntooManyMatches%20=%20null,\nlastError%20=%20null;\n\nfunction%20refocus()\n{\n%20%20_in.blur();%20//%20Needed%20for%20Mozilla%20to%20scroll%20correctly.\n%20%20_in.focus();\n}\n\nfunction%20init()\n{\n%20%20_in%20=%20document.getElementById(\%22input\%22);\n%20%20_out%20=%20document.getElementById(\%22output\%22);\n\n%20%20_win%20=%20window;\n\n%20%20if%20(opener%20&&%20!opener.closed)\n%20%20{\n%20%20%20%20println(\%22Using%20bookmarklet%20version%20of%20shell:%20commands%20will%20run%20in%20opener's%20context.\%22,%20\%22message\%22);\n%20%20%20%20_win%20=%20opener;\n%20%20}\n\n%20%20initTarget();\n\n%20%20recalculateInputHeight();\n%20%20refocus();\n}\n\nfunction%20initTarget()\n{\n%20%20_win.Shell%20=%20window;\n%20%20_win.print%20=%20shellCommands.print;\n}\n\n\n//%20Unless%20the%20user%20is%20selected%20something,%20refocus%20the%20textbox.\n//%20(requested%20by%20caillon,%20brendan,%20asa)\nfunction%20keepFocusInTextbox(e)%20\n{\n%20%20var%20g%20=%20e.srcElement%20?%20e.srcElement%20:%20e.target;%20//%20IE%20vs.%20standard\n%20%20\n%20%20while%20(!g.tagName)\n%20%20%20%20g%20=%20g.parentNode;\n%20%20var%20t%20=%20g.tagName.toUpperCase();\n%20%20if%20(t==\%22A\%22%20||%20t==\%22INPUT\%22)\n%20%20%20%20return;\n%20%20%20%20\n%20%20if%20(window.getSelection)%20{\n%20%20%20%20//%20Mozilla\n%20%20%20%20if%20(String(window.getSelection()))\n%20%20%20%20%20%20return;\n%20%20}\n%20%20else%20if%20(document.getSelection)%20{\n%20%20%20%20//%20Opera?%20Netscape%204?\n%20%20%20%20if%20(document.getSelection())\n%20%20%20%20%20%20return;\n%20%20}\n%20%20else%20{\n%20%20%20%20//%20IE\n%20%20%20%20if%20(%20document.selection.createRange().text%20)\n%20%20%20%20%20%20return;\n%20%20}\n%20%20\n%20%20refocus();\n}\n\nfunction%20inputKeydown(e)%20{\n%20%20//%20Use%20onkeydown%20because%20IE%20doesn't%20support%20onkeypress%20for%20arrow%20keys\n\n%20%20//alert(e.keyCode%20+%20\%22%20^%20\%22%20+%20e.keycode);\n\n%20%20if%20(e.shiftKey%20&&%20e.keyCode%20==%2013)%20{%20//%20shift-enter\n%20%20%20%20//%20don't%20do%20anything;%20allow%20the%20shift-enter%20to%20insert%20a%20line%20break%20as%20normal\n%20%20}%20else%20if%20(e.keyCode%20==%2013)%20{%20//%20enter\n%20%20%20%20//%20execute%20the%20input%20on%20enter\n%20%20%20%20try%20{%20go();%20}%20catch(er)%20{%20alert(er);%20};\n%20%20%20%20setTimeout(function()%20{%20_in.value%20=%20\%22\%22;%20},%200);%20//%20can't%20preventDefault%20on%20input,%20so%20clear%20it%20later\n%20%20}%20else%20if%20(e.keyCode%20==%2038)%20{%20//%20up\n%20%20%20%20//%20go%20up%20in%20history%20if%20at%20top%20or%20ctrl-up\n%20%20%20%20if%20(e.ctrlKey%20||%20caretInFirstLine(_in))\n%20%20%20%20%20%20hist(true);\n%20%20}%20else%20if%20(e.keyCode%20==%2040)%20{%20//%20down\n%20%20%20%20//%20go%20down%20in%20history%20if%20at%20end%20or%20ctrl-down\n%20%20%20%20if%20(e.ctrlKey%20||%20caretInLastLine(_in))\n%20%20%20%20%20%20hist(false);\n%20%20}%20else%20if%20(e.keyCode%20==%209)%20{%20//%20tab\n%20%20%20%20tabcomplete();\n%20%20%20%20setTimeout(function()%20{%20refocus();%20},%200);%20//%20refocus%20because%20tab%20was%20hit\n%20%20}%20else%20{%20}\n\n%20%20setTimeout(recalculateInputHeight,%200);\n%20%20\n%20%20//return%20true;\n};\n\nfunction%20caretInFirstLine(textbox)\n{\n%20%20//%20IE%20doesn't%20support%20selectionStart/selectionEnd\n%20%20if%20(textbox.selectionStart%20==%20undefined)\n%20%20%20%20return%20true;\n\n%20%20var%20firstLineBreak%20=%20textbox.value.indexOf(\%22\\n\%22);\n%20%20\n%20%20return%20((firstLineBreak%20==%20-1)%20||%20(textbox.selectionStart%20%3C=%20firstLineBreak));\n}\n\nfunction%20caretInLastLine(textbox)\n{\n%20%20//%20IE%20doesn't%20support%20selectionStart/selectionEnd\n%20%20if%20(textbox.selectionEnd%20==%20undefined)\n%20%20%20%20return%20true;\n\n%20%20var%20lastLineBreak%20=%20textbox.value.lastIndexOf(\%22\\n\%22);\n%20%20\n%20%20return%20(textbox.selectionEnd%20%3E%20lastLineBreak);\n}\n\nfunction%20recalculateInputHeight()\n{\n%20%20var%20rows%20=%20_in.value.split(/\\n/).length\n%20%20%20%20+%201%20//%20prevent%20scrollbar%20flickering%20in%20Mozilla\n%20%20%20%20+%20(window.opera%20?%201%20:%200);%20//%20leave%20room%20for%20scrollbar%20in%20Opera\n%20%20\n%20%20if%20(_in.rows%20!=%20rows)%20//%20without%20this%20check,%20it%20is%20impossible%20to%20select%20text%20in%20Opera%207.60%20or%20Opera%208.0.\n%20%20%20%20_in.rows%20=%20rows;\n}\n\nfunction%20println(s,%20type)\n{\n%20%20if((s=String(s)))\n%20%20{\n%20%20%20%20var%20newdiv%20=%20document.createElement(\%22div\%22);\n%20%20%20%20newdiv.appendChild(document.createTextNode(s));\n%20%20%20%20newdiv.className%20=%20type;\n%20%20%20%20_out.appendChild(newdiv);\n%20%20%20%20return%20newdiv;\n%20%20}\n}\n\nfunction%20printWithRunin(h,%20s,%20type)\n{\n%20%20var%20div%20=%20println(s,%20type);\n%20%20var%20head%20=%20document.createElement(\%22strong\%22);\n%20%20head.appendChild(document.createTextNode(h%20+%20\%22:%20\%22));\n%20%20div.insertBefore(head,%20div.firstChild);\n}\n\n\nvar%20shellCommands%20=%20\n{\nload%20:%20function%20load(url)\n{\n%20%20var%20s%20=%20_win.document.createElement(\%22script\%22);\n%20%20s.type%20=%20\%22text/javascript\%22;\n%20%20s.src%20=%20url;\n%20%20_win.document.getElementsByTagName(\%22head\%22)[0].appendChild(s);\n%20%20println(\%22Loading%20\%22%20+%20url%20+%20\%22...\%22,%20\%22message\%22);\n},\n\nclear%20:%20function%20clear()\n{\n%20%20var%20CHILDREN_TO_PRESERVE%20=%203;\n%20%20while%20(_out.childNodes[CHILDREN_TO_PRESERVE])%20\n%20%20%20%20_out.removeChild(_out.childNodes[CHILDREN_TO_PRESERVE]);\n},\n\nprint%20:%20function%20print(s)%20{%20println(s,%20\%22print\%22);%20},\n\n//%20the%20normal%20function,%20\%22print\%22,%20shouldn't%20return%20a%20value\n//%20(suggested%20by%20brendan;%20later%20noticed%20it%20was%20a%20problem%20when%20showing%20others)\npr%20:%20function%20pr(s)%20\n{%20\n%20%20shellCommands.print(s);%20//%20need%20to%20specify%20shellCommands%20so%20it%20doesn't%20try%20window.print()!\n%20%20return%20s;\n},\n\nprops%20:%20function%20props(e,%20onePerLine)\n{\n%20%20if%20(e%20===%20null)%20{\n%20%20%20%20println(\%22props%20called%20with%20null%20argument\%22,%20\%22error\%22);\n%20%20%20%20return;\n%20%20}\n\n%20%20if%20(e%20===%20undefined)%20{\n%20%20%20%20println(\%22props%20called%20with%20undefined%20argument\%22,%20\%22error\%22);\n%20%20%20%20return;\n%20%20}\n\n%20%20var%20ns%20=%20[\%22Methods\%22,%20\%22Fields\%22,%20\%22Unreachables\%22];\n%20%20var%20as%20=%20[[],%20[],%20[]];%20//%20array%20of%20(empty)%20arrays%20of%20arrays!\n%20%20var%20p,%20j,%20i;%20//%20loop%20variables,%20several%20used%20multiple%20times\n\n%20%20var%20protoLevels%20=%200;\n\n%20%20for%20(p%20=%20e;%20p;%20p%20=%20p.__proto__)\n%20%20{\n%20%20%20%20for%20(i=0;%20i%3Cns.length;%20++i)\n%20%20%20%20%20%20as[i][protoLevels]%20=%20[];\n%20%20%20%20++protoLevels;\n%20%20}\n\n%20%20for(var%20a%20in%20e)\n%20%20{\n%20%20%20%20//%20Shortcoming:%20doesn't%20check%20that%20VALUES%20are%20the%20same%20in%20object%20and%20prototype.\n\n%20%20%20%20var%20protoLevel%20=%20-1;\n%20%20%20%20try\n%20%20%20%20{\n%20%20%20%20%20%20for%20(p%20=%20e;%20p%20&&%20(a%20in%20p);%20p%20=%20p.__proto__)\n%20%20%20%20%20%20%20%20++protoLevel;\n%20%20%20%20}\n%20%20%20%20catch(er)%20{%20protoLevel%20=%200;%20}%20//%20\%22in\%22%20operator%20throws%20when%20param%20to%20props()%20is%20a%20string\n\n%20%20%20%20var%20type%20=%201;\n%20%20%20%20try\n%20%20%20%20{\n%20%20%20%20%20%20if%20((typeof%20e[a])%20==%20\%22function\%22)\n%20%20%20%20%20%20%20%20type%20=%200;\n%20%20%20%20}\n%20%20%20%20catch%20(er)%20{%20type%20=%202;%20}\n\n%20%20%20%20as[type][protoLevel].push(a);\n%20%20}\n\n%20%20function%20times(s,%20n)%20{%20return%20n%20?%20s%20+%20times(s,%20n-1)%20:%20\%22\%22;%20}\n\n%20%20for%20(j=0;%20j%3CprotoLevels;%20++j)\n%20%20%20%20for%20(i=0;i%3Cns.length;++i)\n%20%20%20%20%20%20if%20(as[i][j].length)%20\n%20%20%20%20%20%20%20%20printWithRunin(\n%20%20%20%20%20%20%20%20%20%20ns[i]%20+%20times(\%22%20of%20prototype\%22,%20j),%20\n%20%20%20%20%20%20%20%20%20%20(onePerLine%20?%20\%22\\n\\n\%22%20:%20\%22\%22)%20+%20as[i][j].sort().join(onePerLine%20?%20\%22\\n\%22%20:%20\%22,%20\%22)%20+%20(onePerLine%20?%20\%22\\n\\n\%22%20:%20\%22\%22),%20\n%20%20%20%20%20%20%20%20%20%20\%22propList\%22\n%20%20%20%20%20%20%20%20);\n},\n\nblink%20:%20function%20blink(node)\n{\n%20%20if%20(!node)%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20throw(\%22blink:%20argument%20is%20null%20or%20undefined.\%22);\n%20%20if%20(node.nodeType%20==%20null)%20%20%20%20%20throw(\%22blink:%20argument%20must%20be%20a%20node.\%22);\n%20%20if%20(node.nodeType%20==%203)%20%20%20%20%20%20%20%20throw(\%22blink:%20argument%20must%20not%20be%20a%20text%20node\%22);\n%20%20if%20(node.documentElement)%20%20%20%20%20%20throw(\%22blink:%20argument%20must%20not%20be%20the%20document%20object\%22);\n\n%20%20function%20setOutline(o)%20{%20\n%20%20%20%20return%20function()%20{\n%20%20%20%20%20%20if%20(node.style.outline%20!=%20node.style.bogusProperty)%20{\n%20%20%20%20%20%20%20%20//%20browser%20supports%20outline%20(Firefox%201.1%20and%20newer,%20CSS3,%20Opera%208).\n%20%20%20%20%20%20%20%20node.style.outline%20=%20o;\n%20%20%20%20%20%20}\n%20%20%20%20%20%20else%20if%20(node.style.MozOutline%20!=%20node.style.bogusProperty)%20{\n%20%20%20%20%20%20%20%20//%20browser%20supports%20MozOutline%20(Firefox%201.0.x%20and%20older)\n%20%20%20%20%20%20%20%20node.style.MozOutline%20=%20o;\n%20%20%20%20%20%20}\n%20%20%20%20%20%20else%20{\n%20%20%20%20%20%20%20%20//%20browser%20only%20supports%20border%20(IE).%20border%20is%20a%20fallback%20because%20it%20moves%20things%20around.\n%20%20%20%20%20%20%20%20node.style.border%20=%20o;\n%20%20%20%20%20%20}\n%20%20%20%20}\n%20%20}%20\n%20%20\n%20%20function%20focusIt(a)%20{\n%20%20%20%20return%20function()%20{\n%20%20%20%20%20%20a.focus();%20\n%20%20%20%20}\n%20%20}\n\n%20%20if%20(node.ownerDocument)%20{\n%20%20%20%20var%20windowToFocusNow%20=%20(node.ownerDocument.defaultView%20||%20node.ownerDocument.parentWindow);%20//%20Moz%20vs.%20IE\n%20%20%20%20if%20(windowToFocusNow)\n%20%20%20%20%20%20setTimeout(focusIt(windowToFocusNow.top),%200);\n%20%20}\n\n%20%20for(var%20i=1;i%3C7;++i)\n%20%20%20%20setTimeout(setOutline((i%252)?'3px%20solid%20red':'none'),%20i*100);\n\n%20%20setTimeout(focusIt(window),%20800);\n%20%20setTimeout(focusIt(_in),%20810);\n},\n\nscope%20:%20function%20scope(sc)\n{\n%20%20if%20(!sc)%20sc%20=%20{};\n%20%20_scope%20=%20sc;\n%20%20println(\%22Scope%20is%20now%20\%22%20+%20sc%20+%20\%22.%20%20If%20a%20variable%20is%20not%20found%20in%20this%20scope,%20window%20will%20also%20be%20searched.%20%20New%20variables%20will%20still%20go%20on%20window.\%22,%20\%22message\%22);\n},\n\nmathHelp%20:%20function%20mathHelp()\n{\n%20%20printWithRunin(\%22Math%20constants\%22,%20\%22E,%20LN2,%20LN10,%20LOG2E,%20LOG10E,%20PI,%20SQRT1_2,%20SQRT2\%22,%20\%22propList\%22);\n%20%20printWithRunin(\%22Math%20methods\%22,%20\%22abs,%20acos,%20asin,%20atan,%20atan2,%20ceil,%20cos,%20exp,%20floor,%20log,%20max,%20min,%20pow,%20random,%20round,%20sin,%20sqrt,%20tan\%22,%20\%22propList\%22);\n},\n\nans%20:%20undefined\n};\n\n\nfunction%20hist(up)\n{\n%20%20//%20histList[0]%20=%20first%20command%20entered,%20[1]%20=%20second,%20etc.\n%20%20//%20type%20something,%20press%20up%20--%3E%20thing%20typed%20is%20now%20in%20\%22limbo\%22\n%20%20//%20(last%20item%20in%20histList)%20and%20should%20be%20reachable%20by%20pressing%20\n%20%20//%20down%20again.\n\n%20%20var%20L%20=%20histList.length;\n\n%20%20if%20(L%20==%201)\n%20%20%20%20return;\n\n%20%20if%20(up)\n%20%20{\n%20%20%20%20if%20(histPos%20==%20L-1)\n%20%20%20%20{\n%20%20%20%20%20%20//%20Save%20this%20entry%20in%20case%20the%20user%20hits%20the%20down%20key.\n%20%20%20%20%20%20histList[histPos]%20=%20_in.value;\n%20%20%20%20}\n\n%20%20%20%20if%20(histPos%20%3E%200)\n%20%20%20%20{\n%20%20%20%20%20%20histPos--;\n%20%20%20%20%20%20//%20Use%20a%20timeout%20to%20prevent%20up%20from%20moving%20cursor%20within%20new%20text\n%20%20%20%20%20%20//%20Set%20to%20nothing%20first%20for%20the%20same%20reason\n%20%20%20%20%20%20setTimeout(\n%20%20%20%20%20%20%20%20function()%20{\n%20%20%20%20%20%20%20%20%20%20_in.value%20=%20'';%20\n%20%20%20%20%20%20%20%20%20%20_in.value%20=%20histList[histPos];\n%20%20%20%20%20%20%20%20%20%20var%20caretPos%20=%20_in.value.length;\n%20%20%20%20%20%20%20%20%20%20if%20(_in.setSelectionRange)%20\n%20%20%20%20%20%20%20%20%20%20%20%20_in.setSelectionRange(caretPos,%20caretPos);\n%20%20%20%20%20%20%20%20},\n%20%20%20%20%20%20%20%200\n%20%20%20%20%20%20);\n%20%20%20%20}\n%20%20}%20\n%20%20else%20//%20down\n%20%20{\n%20%20%20%20if%20(histPos%20%3C%20L-1)\n%20%20%20%20{\n%20%20%20%20%20%20histPos++;\n%20%20%20%20%20%20_in.value%20=%20histList[histPos];\n%20%20%20%20}\n%20%20%20%20else%20if%20(histPos%20==%20L-1)\n%20%20%20%20{\n%20%20%20%20%20%20//%20Already%20on%20the%20current%20entry:%20clear%20but%20save\n%20%20%20%20%20%20if%20(_in.value)\n%20%20%20%20%20%20{\n%20%20%20%20%20%20%20%20histList[histPos]%20=%20_in.value;\n%20%20%20%20%20%20%20%20++histPos;\n%20%20%20%20%20%20%20%20_in.value%20=%20\%22\%22;\n%20%20%20%20%20%20}\n%20%20%20%20}\n%20%20}\n}\n\nfunction%20tabcomplete()\n{\n%20%20/*\n%20%20%20*%20Working%20backwards%20from%20s[from],%20find%20the%20spot\n%20%20%20*%20where%20this%20expression%20starts.%20%20It%20will%20scan\n%20%20%20*%20until%20it%20hits%20a%20mismatched%20(%20or%20a%20space,\n%20%20%20*%20but%20it%20skips%20over%20quoted%20strings.\n%20%20%20*%20If%20stopAtDot%20is%20true,%20stop%20at%20a%20'.'\n%20%20%20*/\n%20%20function%20findbeginning(s,%20from,%20stopAtDot)\n%20%20{\n%20%20%20%20/*\n%20%20%20%20%20*%20%20Complicated%20function.\n%20%20%20%20%20*\n%20%20%20%20%20*%20%20Return%20true%20if%20s[i]%20==%20q%20BUT%20ONLY%20IF\n%20%20%20%20%20*%20%20s[i-1]%20is%20not%20a%20backslash.\n%20%20%20%20%20*/\n%20%20%20%20function%20equalButNotEscaped(s,i,q)\n%20%20%20%20{\n%20%20%20%20%20%20if(s.charAt(i)%20!=%20q)%20//%20not%20equal%20go%20no%20further\n%20%20%20%20%20%20%20%20return%20false;\n\n%20%20%20%20%20%20if(i==0)%20//%20beginning%20of%20string\n%20%20%20%20%20%20%20%20return%20true;\n\n%20%20%20%20%20%20if(s.charAt(i-1)%20==%20'\\\\')%20//%20escaped?\n%20%20%20%20%20%20%20%20return%20false;\n\n%20%20%20%20%20%20return%20true;\n%20%20%20%20}\n\n%20%20%20%20var%20nparens%20=%200;\n%20%20%20%20var%20i;\n%20%20%20%20for(i=from;%20i%3E=0;%20i--)\n%20%20%20%20{\n%20%20%20%20%20%20if(s.charAt(i)%20==%20'%20')\n%20%20%20%20%20%20%20%20break;\n\n%20%20%20%20%20%20if(stopAtDot%20&&%20s.charAt(i)%20==%20'.')\n%20%20%20%20%20%20%20%20break;\n%20%20%20%20%20%20%20%20\n%20%20%20%20%20%20if(s.charAt(i)%20==%20')')\n%20%20%20%20%20%20%20%20nparens++;\n%20%20%20%20%20%20else%20if(s.charAt(i)%20==%20'(')\n%20%20%20%20%20%20%20%20nparens--;\n\n%20%20%20%20%20%20if(nparens%20%3C%200)\n%20%20%20%20%20%20%20%20break;\n\n%20%20%20%20%20%20//%20skip%20quoted%20strings\n%20%20%20%20%20%20if(s.charAt(i)%20==%20'\\''%20||%20s.charAt(i)%20==%20'\\\%22')\n%20%20%20%20%20%20{\n%20%20%20%20%20%20%20%20//dump(\%22skipping%20quoted%20chars:%20\%22);\n%20%20%20%20%20%20%20%20var%20quot%20=%20s.charAt(i);\n%20%20%20%20%20%20%20%20i--;\n%20%20%20%20%20%20%20%20while(i%20%3E=%200%20&&%20!equalButNotEscaped(s,i,quot))%20{\n%20%20%20%20%20%20%20%20%20%20//dump(s.charAt(i));\n%20%20%20%20%20%20%20%20%20%20i--;\n%20%20%20%20%20%20%20%20}\n%20%20%20%20%20%20%20%20//dump(\%22\\n\%22);\n%20%20%20%20%20%20}\n%20%20%20%20}\n%20%20%20%20return%20i;\n%20%20}\n\n%20%20//%20XXX%20should%20be%20used%20more%20consistently%20(instead%20of%20using%20selectionStart/selectionEnd%20throughout%20code)\n%20%20//%20XXX%20doesn't%20work%20in%20IE,%20even%20though%20it%20contains%20IE-specific%20code\n%20%20function%20getcaretpos(inp)\n%20%20{\n%20%20%20%20if(inp.selectionEnd%20!=%20null)\n%20%20%20%20%20%20return%20inp.selectionEnd;\n%20%20%20%20%20%20\n%20%20%20%20if(inp.createTextRange)\n%20%20%20%20{\n%20%20%20%20%20%20var%20docrange%20=%20_win.Shell.document.selection.createRange();\n%20%20%20%20%20%20var%20inprange%20=%20inp.createTextRange();\n%20%20%20%20%20%20if%20(inprange.setEndPoint)\n%20%20%20%20%20%20{\n%20%20%20%20%20%20%20%20inprange.setEndPoint('EndToStart',%20docrange);\n%20%20%20%20%20%20%20%20return%20inprange.text.length;\n%20%20%20%20%20%20}\n%20%20%20%20}\n\n%20%20%20%20return%20inp.value.length;%20//%20sucks,%20punt\n%20%20}\n\n%20%20function%20setselectionto(inp,pos)\n%20%20{\n%20%20%20%20if(inp.selectionStart)%20{\n%20%20%20%20%20%20inp.selectionStart%20=%20inp.selectionEnd%20=%20pos;\n%20%20%20%20}\n%20%20%20%20else%20if(inp.createTextRange)%20{\n%20%20%20%20%20%20var%20docrange%20=%20_win.Shell.document.selection.createRange();\n%20%20%20%20%20%20var%20inprange%20=%20inp.createTextRange();\n%20%20%20%20%20%20inprange.move('character',pos);\n%20%20%20%20%20%20inprange.select();\n%20%20%20%20}\n%20%20%20%20else%20{%20//%20err...\n%20%20%20%20/*\n%20%20%20%20%20%20inp.select();\n%20%20%20%20%20%20if(_win.Shell.document.getSelection())\n%20%20%20%20%20%20%20%20_win.Shell.document.getSelection()%20=%20\%22\%22;\n%20%20%20%20%20%20%20%20*/\n%20%20%20%20}\n%20%20}\n%20%20%20%20//%20get%20position%20of%20cursor%20within%20the%20input%20box\n%20%20%20%20var%20caret%20=%20getcaretpos(_in);\n\n%20%20%20%20if(caret)%20{\n%20%20%20%20%20%20//dump(\%22----\\n\%22);\n%20%20%20%20%20%20var%20dotpos,%20spacepos,%20complete,%20obj;\n%20%20%20%20%20%20//dump(\%22caret%20pos:%20\%22%20+%20caret%20+%20\%22\\n\%22);\n%20%20%20%20%20%20//%20see%20if%20there's%20a%20dot%20before%20here\n%20%20%20%20%20%20dotpos%20=%20findbeginning(_in.value,%20caret-1,%20true);\n%20%20%20%20%20%20//dump(\%22dot%20pos:%20\%22%20+%20dotpos%20+%20\%22\\n\%22);\n%20%20%20%20%20%20if(dotpos%20==%20-1%20||%20_in.value.charAt(dotpos)%20!=%20'.')%20{\n%20%20%20%20%20%20%20%20dotpos%20=%20caret;\n//dump(\%22changed%20dot%20pos:%20\%22%20+%20dotpos%20+%20\%22\\n\%22);\n%20%20%20%20%20%20}\n\n%20%20%20%20%20%20//%20look%20backwards%20for%20a%20non-variable-name%20character\n%20%20%20%20%20%20spacepos%20=%20findbeginning(_in.value,%20dotpos-1,%20false);\n%20%20%20%20%20%20//dump(\%22space%20pos:%20\%22%20+%20spacepos%20+%20\%22\\n\%22);\n%20%20%20%20%20%20//%20get%20the%20object%20we're%20trying%20to%20complete%20on\n%20%20%20%20%20%20if(spacepos%20==%20dotpos%20||%20spacepos+1%20==%20dotpos%20||%20dotpos%20==%20caret)\n%20%20%20%20%20%20{\n%20%20%20%20%20%20%20%20//%20try%20completing%20function%20args\n%20%20%20%20%20%20%20%20if(_in.value.charAt(dotpos)%20==%20'('%20||\n%20(_in.value.charAt(spacepos)%20==%20'('%20&&%20(spacepos+1)%20==%20dotpos))\n%20%20%20%20%20%20%20%20{\n%20%20%20%20%20%20%20%20%20%20var%20fn,fname;\n%20%20var%20from%20=%20(_in.value.charAt(dotpos)%20==%20'(')%20?%20dotpos%20:%20spacepos;\n%20%20%20%20%20%20%20%20%20%20spacepos%20=%20findbeginning(_in.value,%20from-1,%20false);\n\n%20%20%20%20%20%20%20%20%20%20fname%20=%20_in.value.substr(spacepos+1,from-(spacepos+1));\n%20%20//dump(\%22fname:%20\%22%20+%20fname%20+%20\%22\\n\%22);\n%20%20%20%20%20%20%20%20%20%20try%20{\n%20%20%20%20%20%20%20%20%20%20%20%20with(_win.Shell._scope)\n%20%20%20%20%20%20%20%20%20%20%20%20%20%20with(_win)\n%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20with(Shell.shellCommands)\n%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20fn%20=%20eval(fname);\n%20%20%20%20%20%20%20%20%20%20}\n%20%20%20%20%20%20%20%20%20%20catch(er)%20{\n%20%20%20%20%20%20%20%20%20%20%20%20//dump('fn%20is%20not%20a%20valid%20object\\n');\n%20%20%20%20%20%20%20%20%20%20%20%20return;\n%20%20%20%20%20%20%20%20%20%20}\n%20%20%20%20%20%20%20%20%20%20if(fn%20==%20undefined)%20{\n%20%20%20%20%20%20%20%20%20%20%20%20%20//dump('fn%20is%20undefined');\n%20%20%20%20%20%20%20%20%20%20%20%20%20return;\n%20%20%20%20%20%20%20%20%20%20}\n%20%20%20%20%20%20%20%20%20%20if(fn%20instanceof%20Function)\n%20%20%20%20%20%20%20%20%20%20{\n%20%20%20%20%20%20%20%20%20%20%20%20//%20Print%20function%20definition,%20including%20argument%20names,%20but%20not%20function%20body\n%20%20%20%20%20%20%20%20%20%20%20%20if(!fn.toString().match(/function%20.+?\\(\\)%20+\\{\\n%20+\\[native%20code\\]\\n\\}/))\n%20%20%20%20%20%20%20%20%20%20%20%20%20%20println(fn.toString().match(/function%20.+?\\(.*?\\)/),%20\%22tabcomplete\%22);\n%20%20%20%20%20%20%20%20%20%20}\n\n%20%20%20%20%20%20%20%20%20%20return;\n%20%20%20%20%20%20%20%20}\n%20%20%20%20%20%20%20%20else\n%20%20%20%20%20%20%20%20%20%20obj%20=%20_win;\n%20%20%20%20%20%20}\n%20%20%20%20%20%20else\n%20%20%20%20%20%20{\n%20%20%20%20%20%20%20%20var%20objname%20=%20_in.value.substr(spacepos+1,dotpos-(spacepos+1));\n%20%20%20%20%20%20%20%20//dump(\%22objname:%20|\%22%20+%20objname%20+%20\%22|\\n\%22);\n%20%20%20%20%20%20%20%20try%20{\n%20%20%20%20%20%20%20%20%20%20with(_win.Shell._scope)\n%20%20%20%20%20%20%20%20%20%20%20%20with(_win)\n%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20obj%20=%20eval(objname);\n%20%20%20%20%20%20%20%20}\n%20%20%20%20%20%20%20%20catch(er)%20{\n%20%20%20%20%20%20%20%20%20%20printError(er);%20\n%20%20%20%20%20%20%20%20%20%20return;\n%20%20%20%20%20%20%20%20}\n%20%20%20%20%20%20%20%20if(obj%20==%20undefined)%20{\n%20%20%20%20%20%20%20%20%20%20//%20sometimes%20this%20is%20tabcomplete's%20fault,%20so%20don't%20print%20it%20:(\n%20%20%20%20%20%20%20%20%20%20//%20e.g.%20completing%20from%20\%22print(document.getElements\%22\n%20%20%20%20%20%20%20%20%20%20//%20println(\%22Can't%20complete%20from%20null%20or%20undefined%20expression%20\%22%20+%20objname,%20\%22error\%22);\n%20%20%20%20%20%20%20%20%20%20return;\n%20%20%20%20%20%20%20%20}\n%20%20%20%20%20%20}\n%20%20%20%20%20%20//dump(\%22obj:%20\%22%20+%20obj%20+%20\%22\\n\%22);\n%20%20%20%20%20%20//%20get%20the%20thing%20we're%20trying%20to%20complete\n%20%20%20%20%20%20if(dotpos%20==%20caret)\n%20%20%20%20%20%20{\n%20%20%20%20%20%20%20%20if(spacepos+1%20==%20dotpos%20||%20spacepos%20==%20dotpos)\n%20%20%20%20%20%20%20%20{\n%20%20%20%20%20%20%20%20%20%20//%20nothing%20to%20complete\n%20%20%20%20%20%20%20%20%20%20//dump(\%22nothing%20to%20complete\\n\%22);\n%20%20%20%20%20%20%20%20%20%20return;\n%20%20%20%20%20%20%20%20}\n\n%20%20%20%20%20%20%20%20complete%20=%20_in.value.substr(spacepos+1,dotpos-(spacepos+1));\n%20%20%20%20%20%20}\n%20%20%20%20%20%20else%20{\n%20%20%20%20%20%20%20%20complete%20=%20_in.value.substr(dotpos+1,caret-(dotpos+1));\n%20%20%20%20%20%20}\n%20%20%20%20%20%20//dump(\%22complete:%20\%22%20+%20complete%20+%20\%22\\n\%22);\n%20%20%20%20%20%20//%20ok,%20now%20look%20at%20all%20the%20props/methods%20of%20this%20obj\n%20%20%20%20%20%20//%20and%20find%20ones%20starting%20with%20'complete'\n%20%20%20%20%20%20var%20matches%20=%20[];\n%20%20%20%20%20%20var%20bestmatch%20=%20null;\n%20%20%20%20%20%20for(var%20a%20in%20obj)\n%20%20%20%20%20%20{\n%20%20%20%20%20%20%20%20//a%20=%20a.toString();\n%20%20%20%20%20%20%20%20//XXX:%20making%20it%20lowercase%20could%20help%20some%20cases,\n%20%20%20%20%20%20%20%20//%20but%20screws%20up%20my%20general%20logic.\n%20%20%20%20%20%20%20%20if(a.substr(0,complete.length)%20==%20complete)%20{\n%20%20%20%20%20%20%20%20%20%20matches.push(a);\n%20%20%20%20%20%20%20%20%20%20////dump(\%22match:%20\%22%20+%20a%20+%20\%22\\n\%22);\n%20%20%20%20%20%20%20%20%20%20//%20if%20no%20best%20match,%20this%20is%20the%20best%20match\n%20%20%20%20%20%20%20%20%20%20if(bestmatch%20==%20null)\n%20%20%20%20%20%20%20%20%20%20{\n%20%20%20%20%20%20%20%20%20%20%20%20bestmatch%20=%20a;\n%20%20%20%20%20%20%20%20%20%20}\n%20%20%20%20%20%20%20%20%20%20else%20{\n%20%20%20%20%20%20%20%20%20%20%20%20//%20the%20best%20match%20is%20the%20longest%20common%20string\n%20%20%20%20%20%20%20%20%20%20%20%20function%20min(a,b){%20return%20((a%3Cb)?a:b);%20}\n%20%20%20%20%20%20%20%20%20%20%20%20var%20i;\n%20%20%20%20%20%20%20%20%20%20%20%20for(i=0;%20i%3C%20min(bestmatch.length,%20a.length);%20i++)\n%20%20%20%20%20%20%20%20%20%20%20%20{\n%20%20%20%20%20%20%20%20%20%20%20%20%20%20if(bestmatch.charAt(i)%20!=%20a.charAt(i))\n%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20break;\n%20%20%20%20%20%20%20%20%20%20%20%20}\n%20%20%20%20%20%20%20%20%20%20%20%20bestmatch%20=%20bestmatch.substr(0,i);\n%20%20%20%20%20%20%20%20%20%20%20%20////dump(\%22bestmatch%20len:%20\%22%20+%20i%20+%20\%22\\n\%22);\n%20%20%20%20%20%20%20%20%20%20}\n%20%20%20%20%20%20%20%20%20%20////dump(\%22bestmatch:%20\%22%20+%20bestmatch%20+%20\%22\\n\%22);\n%20%20%20%20%20%20%20%20}\n%20%20%20%20%20%20}\n%20%20%20%20%20%20bestmatch%20=%20(bestmatch%20||%20\%22\%22);\n%20%20%20%20%20%20////dump(\%22matches:%20\%22%20+%20matches%20+%20\%22\\n\%22);\n%20%20%20%20%20%20var%20objAndComplete%20=%20(objname%20||%20obj)%20+%20\%22.\%22%20+%20bestmatch;\n%20%20%20%20%20%20//dump(\%22matches.length:%20\%22%20+%20matches.length%20+%20\%22,%20tooManyMatches:%20\%22%20+%20tooManyMatches%20+%20\%22,%20objAndComplete:%20\%22%20+%20objAndComplete%20+%20\%22\\n\%22);\n%20%20%20%20%20%20if(matches.length%20%3E%201%20&&%20(tooManyMatches%20==%20objAndComplete%20||%20matches.length%20%3C=%2010))%20{\n\n%20%20%20%20%20%20%20%20printWithRunin(\%22Matches:%20\%22,%20matches.join(',%20'),%20\%22tabcomplete\%22);\n%20%20%20%20%20%20%20%20tooManyMatches%20=%20null;\n%20%20%20%20%20%20}\n%20%20%20%20%20%20else%20if(matches.length%20%3E%2010)\n%20%20%20%20%20%20{\n%20%20%20%20%20%20%20%20println(matches.length%20+%20\%22%20matches.%20%20Press%20tab%20again%20to%20see%20them%20all\%22,%20\%22tabcomplete\%22);\n%20%20%20%20%20%20%20%20tooManyMatches%20=%20objAndComplete;\n%20%20%20%20%20%20}\n%20%20%20%20%20%20else%20{\n%20%20%20%20%20%20%20%20tooManyMatches%20=%20null;\n%20%20%20%20%20%20}\n%20%20%20%20%20%20if(bestmatch%20!=%20\%22\%22)\n%20%20%20%20%20%20{\n%20%20%20%20%20%20%20%20var%20sstart;\n%20%20%20%20%20%20%20%20if(dotpos%20==%20caret)%20{\n%20%20%20%20%20%20%20%20%20%20sstart%20=%20spacepos+1;\n%20%20%20%20%20%20%20%20}\n%20%20%20%20%20%20%20%20else%20{\n%20%20%20%20%20%20%20%20%20%20sstart%20=%20dotpos+1;\n%20%20%20%20%20%20%20%20}\n%20%20%20%20%20%20%20%20_in.value%20=%20_in.value.substr(0,%20sstart)\n%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20+%20bestmatch\n%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20+%20_in.value.substr(caret);\n%20%20%20%20%20%20%20%20setselectionto(_in,caret%20+%20(bestmatch.length%20-%20complete.length));\n%20%20%20%20%20%20}\n%20%20%20%20}\n}\n\nfunction%20printQuestion(q)\n{\n%20%20println(q,%20\%22input\%22);\n}\n\nfunction%20printAnswer(a)\n{\n%20%20if%20(a%20!==%20undefined)%20{\n%20%20%20%20println(a,%20\%22normalOutput\%22);\n%20%20%20%20shellCommands.ans%20=%20a;\n%20%20}\n}\n\nfunction%20printError(er)\n{%20\n%20%20var%20lineNumberString;\n\n%20%20lastError%20=%20er;%20//%20for%20debugging%20the%20shell\n%20%20if%20(er.name)\n%20%20{\n%20%20%20%20//%20lineNumberString%20should%20not%20be%20\%22\%22,%20to%20avoid%20a%20very%20wacky%20bug%20in%20IE%206.\n%20%20%20%20lineNumberString%20=%20(er.lineNumber%20!=%20undefined)%20?%20(\%22%20on%20line%20\%22%20+%20er.lineNumber%20+%20\%22:%20\%22)%20:%20\%22:%20\%22;\n%20%20%20%20println(er.name%20+%20lineNumberString%20+%20er.message,%20\%22error\%22);%20//%20Because%20IE%20doesn't%20have%20error.toString.\n%20%20}\n%20%20else\n%20%20%20%20println(er,%20\%22error\%22);%20//%20Because%20security%20errors%20in%20Moz%20/only/%20have%20toString.\n}\n\nfunction%20go(s)\n{\n%20%20_in.value%20=%20question%20=%20s%20?%20s%20:%20_in.value;\n\n%20%20if%20(question%20==%20\%22\%22)\n%20%20%20%20return;\n\n%20%20histList[histList.length-1]%20=%20question;\n%20%20histList[histList.length]%20=%20\%22\%22;\n%20%20histPos%20=%20histList.length%20-%201;\n%20%20\n%20%20//%20Unfortunately,%20this%20has%20to%20happen%20*before*%20the%20JavaScript%20is%20run,%20so%20that%20\n%20%20//%20print()%20output%20will%20go%20in%20the%20right%20place.\n%20%20_in.value='';\n%20%20recalculateInputHeight();\n%20%20printQuestion(question);\n\n%20%20if%20(_win.closed)%20{\n%20%20%20%20printError(\%22Target%20window%20has%20been%20closed.\%22);\n%20%20%20%20return;\n%20%20}\n%20%20\n%20%20try%20{%20(\%22Shell\%22%20in%20_win)%20}\n%20%20catch(er)%20{\n%20%20%20%20printError(\%22The%20JavaScript%20Shell%20cannot%20access%20variables%20in%20the%20target%20window.%20%20The%20most%20likely%20reason%20is%20that%20the%20target%20window%20now%20has%20a%20different%20page%20loaded%20and%20that%20page%20has%20a%20different%20hostname%20than%20the%20original%20page.\%22);\n%20%20%20%20return;\n%20%20}\n\n%20%20if%20(!(\%22Shell\%22%20in%20_win))\n%20%20%20%20initTarget();%20//%20silent\n\n%20%20//%20Evaluate%20Shell.question%20using%20_win's%20eval%20(this%20is%20why%20eval%20isn't%20in%20the%20|with|,%20IIRC).\n%20%20_win.location.href%20=%20\%22javascript:try{%20Shell.printAnswer(eval('with(Shell._scope)%20with(Shell.shellCommands)%20{'%20+%20Shell.question%20+%20String.fromCharCode(10)%20+%20'}'));%20}%20catch(er)%20{%20Shell.printError(er);%20};%20setTimeout(Shell.refocus,%200);%20void%200\%22;\n}\n\n%3C/script%3E\n\n%3C!--%20for%20http://ted.mielczarek.org/code/mozilla/extensiondev/%20--%3E\n%3Cscript%20type=\%22text/javascript\%22%20src=\%22chrome://extensiondev/content/rdfhistory.js\%22%3E%3C/script%3E\n%3Cscript%20type=\%22text/javascript\%22%20src=\%22chrome://extensiondev/content/chromeShellExtras.js\%22%3E%3C/script%3E\n\n%3Cstyle%20type=\%22text/css\%22%3E\nbody%20{%20background:%20white;%20color:%20black;%20}\n\n#output%20{%20white-space:%20pre;%20white-space:%20-moz-pre-wrap;%20}%20/*%20Preserve%20line%20breaks,%20but%20wrap%20too%20if%20browser%20supports%20it%20*/\nh3%20{%20margin-top:%200;%20margin-bottom:%200em;%20}\nh3%20+%20div%20{%20margin:%200;%20}\n\nform%20{%20margin:%200;%20padding:%200;%20}\n%23input%20{%20width:%20100%25;%20border:%20none;%20padding:%200;%20overflow:%20auto;%20}\n\n.input%20{%20color:%20blue;%20background:%20white;%20font:%20inherit;%20font-weight:%20bold;%20margin-top:%20.5em;%20/*%20background:%20%23E6E6FF;%20*/%20}\n.normalOutput%20{%20color:%20black;%20background:%20white;%20}\n.print%20{%20color:%20brown;%20background:%20white;%20}\n.error%20{%20color:%20red;%20background:%20white;%20}\n.propList%20{%20color:%20green;%20background:%20white;%20}\n.message%20{%20color:%20green;%20background:%20white;%20}\n.tabcomplete%20{%20color:%20purple;%20background:%20white;%20}\n%3C/style%3E\n%3C/head%3E\n\n%3Cbody%20onload=\%22init()\%22%3E\n\n%3Cdiv%20id=\%22output\%22%3E%3Ch3%3EJavaScript%20Shell%201.4%3C/h3%3E%3Cdiv%3EFeatures:%20autocompletion%20of%20property%20names%20with%20Tab,%20multiline%20input%20with%20Shift+Enter,%20input%20history%20with%20(Ctrl+)%20Up/Down,%20%3Ca%20accesskey=\%22M\%22%20href=\%22javascript:go('scope(Math);%20mathHelp();');\%22%20title=\%22Accesskey:%20M\%22%3EMath%3C/a%3E,%20%3Ca%20accesskey=\%22H\%22%20href=\%22http://www.squarefree.com/shell/?ignoreReferrerFrom=shell1.4\%22%20%20title=\%22Accesskey:%20H\%22%3Ehelp%3C/a%3E%3C/div%3E%3Cdiv%3EValues%20and%20functions:%20ans,%20print(string),%20%3Ca%20accesskey=\%22P\%22%20href=\%22javascript:go('props(ans)')\%22%20title=\%22Accesskey:%20P\%22%3Eprops(object)%3C/a%3E,%20%3Ca%20accesskey=\%22B\%22%20href=\%22javascript:go('blink(ans)')\%22%20title=\%22Accesskey:%20B\%22%3Eblink(node)%3C/a%3E,%20%3Ca%20accesskey=\%22C\%22%20href=\%22javascript:go('clear()')\%22%20title=\%22Acce

Аналогично, но не взаимодействует со страницей

javascript:with(window.open(%22%22,%22_blank%22,%22width=%22+screen.width*.6+%22,left=%22+screen.width*.35+%22,height=%22+screen.height*.9+%22,resizable,scrollbars=yes%22)){document.write(%22%3Chead%3E%3Ctitle%3EJavaScript%20Development%20Environment%202.0.1%3C/title%3E%3C!--%20about:blank%20confuses%20opera..%20--%3E%3C/head%3E%3Cframeset%20rows=\%2225,*,*\%22%3E\n\n%20%20%3Cframe%20name=\%22toolbarFrame\%22%20src=\%22about:blank\%22%20noresize=\%22noresize\%22%3E\n\n%20%20%3Cframe%20name=\%22inputFrame\%22%20src=\%22about:blank\%22%3E\n\n%20%20%3Cframe%20name=\%22outputFrame\%22%20src=\%22about:blank\%22%3E\n\n%3C/frameset%3E\n\n%22);document.close();%20frames[0].document.write(%22%3Chead%3E%3C!--%20no%20doctype%20-%20it%20makes%20IE%20ignore%20the%20height:%20100%25.%20--%3E%3Ctitle%3EtoolbarFrame%3C/title%3E\n\n\n\n%3Cstyle%20type=\%22text/css\%22%3E\nhtml,body%20{%20width:%20100%25;%20height:%20100%25;%20border:%20none;%20margin:%200px;%20padding:%200px;%20}\nbutton%20{%20height:%20100%25;%20}\n%3C/style%3E\n\n%3Cscript%20type=\%22text/javascript\%22%3E\n\nvar%20outputFrame%20=%20parent.outputFrame;\nvar%20inputFrame%20=%20parent.inputFrame;\nvar%20framesetElement%20=%20parent.document.documentElement.getElementsByTagName(\%22frameset\%22)[0];\n\nvar%20savedRows;\n\n\n//%20Need%20to%20use%20C-style%20comments%20in%20handleError()%20and%20print()%20\n//%20because%20IE%20retains%20them%20when%20decompiling%20a%20function.\n\n\n\nfunction%20print(s,%20c)%20{\n%20%20var%20outputFrame%20=%20parent.outputFrame;%20/*%20duplicated%20here%20in%20case%20this%20function%20is%20elsewhere%20*/\n%20%20var%20doc%20=%20outputFrame.document;\n\n%20%20var%20newdiv%20=%20doc.createElement(\%22div\%22);\n%20%20newdiv.appendChild(doc.createTextNode(s));\n%20%20if%20(c)\n%20%20%20%20newdiv.style.color%20=%20c;\n%20%20doc.body.appendChild(newdiv);\n}\n\nfunction%20handleError(er,%20file,%20lineNumber)%20\n{\n%20%20print(\%22Error%20on%20line%20\%22%20+%20lineNumber%20+%20\%22:%20\%22%20+%20er,%20\%22red\%22);%20\n%20%20%20%20\n%20%20/*%20Find%20the%20character%20offset%20for%20the%20line%20*/\n%20%20/*%20(code%20adapted%20from%20blogidate%20xml%20well-formedness%20bookmarklet)%20*/\n%20%20var%20ta%20=%20inputFrame.document.getElementById(\%22input\%22);\n%20%20var%20lines%20=%20ta.value.split(\%22\\n\%22);\n%20%20var%20cc%20=%200;%20\n%20%20var%20i;\n%20%20for(i=0;%20i%20%3C%20(lineNumber%20-%201);%20++i)%20\n%20%20%20%20cc%20+=%20lines[i].length%20+%201;\n\n%20%20/*%20Hacky(?)%20workaround%20for%20IE's%20habit%20of%20including%20\\r's%20in%20strings%20*/\n%20%20if%20(ta.value.split(\%22\\r\%22).length%20%3E%201)\n%20%20%20%20cc%20-=%20lineNumber%20-%201;\n\n%20%20/*%20Select%20the%20line%20*/\n%20%20if(document.selection)%20{%20\n%20%20%20%20/*%20IE%20(Leonard%20Lin%20gave%20me%20this%20code)%20*/\n%20%20%20%20var%20sel%20=%20ta.createTextRange();%20\n%20%20%20%20sel.moveStart(\%22character\%22,%20cc);%20\n%20%20%20%20sel.collapse();%20\n%20%20%20%20sel.moveEnd(\%22character\%22,%20lines[i].length);%20\n%20%20%20%20sel.select();\n%20%20}%20else%20{%20\n%20%20%20%20/*%20Mozilla%20*/\n%20%20%20%20ta.selectionStart%20=%20cc;%20\n%20%20%20%20ta.selectionEnd%20=%20cc%20+%20lines[i].length;%20\n%20%20}\n%20\n%20%20/*%20return%20true;%20*/%20/*%20nah,%20let%20the%20error%20go%20through%20to%20IE's%20js%20consolish%20thing!%20*/\n}\n\n\n\n\n\nfunction%20showHideOutput()\n{\n%20%20if%20(outputFrame.document.body.clientHeight%20%3E%20100)%20{\n%20%20%20%20//%20hide\n%20%20%20%20savedRows%20=%20framesetElement.rows;%20%20%20%20\n%20%20%20%20framesetElement.rows%20=%20\%2225,*,0\%22;\n%20%20}\n%20%20else%20{\n%20%20%20%20//%20show.%20use%20the%20previous%20size,%20if%20possible\n%20%20%20%20if%20(savedRows)%20{\n%20%20%20%20%20%20framesetElement.rows%20=%20savedRows;\n%20%20%20%20%20%20savedRows%20=%20null;\n%20%20%20%20}\n%20%20%20%20else%20{\n%20%20%20%20%20%20framesetElement.rows%20=%20\%2225,*,*\%22;\n%20%20%20%20}\n%20%20}\n}\n\nfunction%20refocus()\n{\n%20%20inputFrame.document.getElementById(\%22input\%22).focus();\n}\n\n\nfunction%20clearOutput()\n{\n%20%20var%20b%20=%20outputFrame.document.body;\n%20%20while(b.firstChild)\n%20%20%20%20b.removeChild(b.firstChild);\n}\n\nfunction%20stripLineBreaks(s)\n{\n%20%20return%20s.replace(/\\n/g,%20\%22\%22).replace(/\\r/g,%20\%22\%22);%20//%20stripping%20\\r%20is%20for%20IE\n}\n\nfunction%20execute()\n{\n%20%20var%20js%20=%20inputFrame.document.getElementById(\%22input\%22).value;\n\n%20%20var%20useOpener%20=%20parent.opener%20&&%20!parent.opener.closed;\n%20%20var%20oldStyle%20=%20!!%20document.all;%20//%20lame%20but%20meh.\n%20%20\n%20%20print(\%22Running\%22%20+%20(useOpener%20?%20\%22%20in%20bookmarklet%20mode\%22%20:%20\%22\%22)%20+%20(oldStyle%20?%20\%22%20in%20make-IE-happy%20mode\%22%20:%20\%22\%22)%20+%20\%22...\%22,%20\%22orange\%22);\n\n%20%20if%20(useOpener)\n%20%20%20%20executeWithJSURL(js,%20parent.opener);%20//%20only%20way%20to%20execute%20against%20another%20frame\n%20%20else%20if%20(oldStyle)\n%20%20%20%20executeWithDW(js,%20execFrame);%20//%20only%20way%20to%20get%20line%20numbers%20in%20IE\n%20%20else\n%20%20%20%20executeWithJSURL(js,%20execFrame);%20//%20faster%20in%20Mozilla%20%20\n}\n\n//%20Advantages:%20can%20get%20line%20numbers%20in%20IE.\nfunction%20executeWithDW(js,%20win)\n{\n%20%20win.document.open();\n%20%20win.inputFrame%20=%20inputFrame;\n%20%20win.outputFrame%20=%20outputFrame;\n%20%20win.document.write(\n%20%20%20%20stripLineBreaks(\n%20%20%20%20%20%20%20%20'%3C!DOCTYPE%20HTML%20PUBLIC%20\%22-//W3C//DTD%20HTML%204.01//EN\%22%20\%22http://www.w3.org/TR/html4/strict.dtd\%22%3E'%20+\n%20%20%20%20%20%20%20%20'%3Chtml%3E%3Chead%3E%3Ctitle%3EexecFrame%3C\\/title%3E%3Cscript%20type=\%22text/javascript\%22%3E'\n%20%20%20%20%20%20+%20print%20%20%20%20%20%20%20%20%20//%20yay%20for%20decompilation!\n%20%20%20%20%20%20+%20handleError%20\n%20%20%20%20%20%20+%20\%22window.onerror%20=%20handleError;\%22\n%20%20%20%20%20%20+%20\%22%3C\\/script%3E%3C\\/head%3E\%22\n%20%20%20%20%20%20)%20\n%20%20%20%20+%20'%3Cbody%3E%3Cscript%20type=\%22text/javascript\%22%3E'\n%20%20%20%20+%20js%20%20%20%20%20%20%20%20%20//%20should%20escape%20it%20a%20little%20to%20remove%20the%20string%20%3C\\/script%3E%20at%20least...\n%20%20%20%20+%20\%22%3C\\/script%3E%3C\\/body%3E%3C\\/html%3E\%22\n%20%20%20%20);\n%20%20win.document.close();\n}\n\n//%20Advantages:%20can%20be%20used%20to%20inject%20a%20script%20into%20another%20window,%20faster%20in%20Mozilla.\nfunction%20executeWithJSURL(js,%20win)\n{\n%20%20//%20isolate%20scope\n%20%20js%20=%20\%22(function(){%20\%22%20+%20js%20+%20\%22%20\\n%20})()\%22;\n\n%20%20win.print%20=%20print;\n%20%20win.onerror%20=%20handleError;\n\n%20%20//%20double%20encodeURIComponent%20because%20javascript:%20URLs%20themselves%20are%20encoded!\n%20%20win.location.href%20=%20'javascript:eval(decodeURIComponent(\%22'%20+%20encodeURIComponent(encodeURIComponent(js))%20+%20'\%22));%20void%200;';\n%20%20\n%20%20refocus();\n}\n\n//%20Other%20ideas%20I%20haven't%20tried%20lately:%20create%20a%20%3Cscript%3E%20element,%20eval.\n\n\nfunction%20makeUserScript(userScriptLink)\n{\n%20%20%20%20userScriptLink.href%20=%20\n%20%20%20%20%20%20%20%20\%22data:text/javascript;charset=utf-8,\%22%20+%20\n%20%20%20%20%20%20%20%20encodeURIComponent(inputFrame.document.getElementById(\%22input\%22).value%20+%20\%22//.user.js\%22);\n}\n\n%3C/script%3E%3C/head%3E%3Cbody%3E\n\n%3Cbutton%20accesskey=\%22E\%22%20onclick=\%22execute();%20refocus();\%22%3E%3Cu%3EE%3C/u%3Execute%3C/button%3E\n%3C!--%20%3Cbutton%20accesskey=\%22R\%22%20onclick=\%22reloadAndExecute();%20refocus();\%22%3E%3Cu%3ER%3C/u%3Eeload%20and%20execute%3C/button%3E%20--%3E\n%3Cbutton%20accesskey=\%22C\%22%20onclick=\%22clearOutput();%20refocus();\%22%3E%3Cu%3EC%3C/u%3Elear%20output%3C/button%3E\n%3Cbutton%20accesskey=\%22S\%22%20onclick=\%22showHideOutput();%20refocus();\%22%3E%3Cu%3ES%3C/u%3Ehow/hide%20output%3C/button%3E\n%3C!--%20%3Cbutton%20accesskey=\%22H\%22%20onclick=\%22help();%20refocus();\%22%3E%3Cu%3EH%3C/u%3Eelp%3C/button%3E%20--%3E\n\n%3Ca%20href=\%22data:text/html,...\%22%20onfocus=\%22makeUserScript(this);\%22%20onmouseover=\%22makeUserScript(this);\%22%20target=\%22_blank\%22%3EInstall%20as%20user%20script%3C/a%3E\n\n%3Cdiv%20style=\%22visibility:%20hidden;\%22%3E\n%3Ciframe%20name=\%22execFrame\%22%20src=\%22about:blank\%22%20height=\%225\%22%20width=\%225\%22%3E%3C/iframe%3E\n%3C/div%3E\n\n%3C/body%3E%22);%20frames[0].document.close();%20frames[1].document.write(%22%3Chead%3E%3C!--%20no%20doctype%20-%20it%20makes%20IE%20ignore%20the%20height:%20100%25.%20--%3E%3Ctitle%3EinputFrame%3C/title%3E\n\n\n\n\n\n%3Cstyle%20type=\%22text/css\%22%3E\n\nhtml,body,form,textarea%20{%20width:%20100%25;%20height:%20100%25;%20border:%20none;%20margin:%200px;%20padding:%200px;%20}\nhtml,body%20{%20overflow:%20hidden;%20}\n\n%3C/style%3E%3C/head%3E%3Cbody%20onload=\%22document.getElementById('input').select();\%22%3E\n%3Ctextarea%20style=\%22background-color:%20rgb(221,%20238,%20255);\%22%20id=\%22input\%22%3E//%20==UserScript==\n//%20@namespace%20%20%20%20%20http://www.squarefree.com/jsenv/autogenerated\n//%20@name%20%20%20%20%20%20%20%20%20%20Unnamed%20script\n//%20@description%20%20%20Undescribed%20script\n//%20==/UserScript==\n\nprint(\%22Squares%20of%20numbers%200%20through%204:\%22);\nfor%20(var%20i%20=%200;%20i%20<%205;%20++i)\n%20%20print(i%20*%20i);\n\nthis.statement.causes(an.error);\n%3C/textarea%3E\n%3C/body%3E%22);%20frames[1].document.close();%20%20%20}void%200

Посмотреть как бы страница смотрелась с другими стилями
javascript:(function(){function%20init(){var%20newline=unescape(%22%%22+%220A%22);dead=false;oldCSS=null;x=opener;ta=document.f.ta;ta.select();ta.value=%22/*%20Type%20CSS%20rules%20here%20and%20they%20will%20be%20applied%20to%22+newline+%22whatever%20page%20is%20loaded%20in%20that%20tab,%20as%20long%20as%20the%20pages%22+newline+%22are%20from%20'%22+location.host+%22'%22+newline+%22and%20you%20keep%20this%20window%20open.%20*/%22+newline+newline;update();}function%20update(){try{if(!x||x.closed){ta.style.backgroundColor=%22#ddd%22;return;}x.bookmarkletStyleSheet;}catch(er){ta.style.backgroundColor=%22%23fdc%22;setTimeout(update,150);dead=true;return;}if(dead){dead=false;ta.style.backgroundColor=%22%22;oldCSS=null;}if(!x.testStyles){var%20newSS;newSS=x.document.createElement(%22link%22);newSS.rel=%22stylesheet%22;newSS.type=%22text/css%22;x.document.getElementsByTagName(%22head%22)[0].appendChild(newSS);x.testStyles=newSS;oldCSS=null;}if(oldCSS!=ta.value){oldCSS=ta.value;if(window.opera)x.testStyles.href=%22javascript:unescape('%22+escape(ta.value)+%22')%22;else%20if(navigator.userAgent.indexOf(%22MSIE%22)!=-1)x.testStyles.href=%22javascript:unescape('%22+escape(escape(ta.value))+%22')%22;else%20x.testStyles.href=%22data:text/css,%22+escape(ta.value);}setTimeout(update,150);}y=window.open('','','resizable,width=500,height=300');y.document.write('%3Ctitle%3ENew%20CSS%20Style%20Sheet%3C/title%3E%3Cstyle%3E.ec%20{%20width:%20100%;%20height:%20100%;%20border:%20none;%20margin:%200px;%20padding:%200px;%20}%3C/style%3E%3Cbody%20class=%22ec%22%3E%3Cform%20name=%22f%22%20style=%22margin:%200px;%22%20class=%22ec%22%3E%3Ctextarea%20name=%22ta%22%20wrap=%22soft%22%20style=%22margin:%200px;%20border:%200px;%20width:100%;%20height:100%;%22%20class=%22ec%22%3E%3C/textarea%3E%3Cscript%3E'+update+init+'init();%3C'+'/script%3E');y.document.close();})()

Посмотреть созданные JS стили.

javascript:(function(){function%20A(n,g){var%20p=n.parentNode,t=n.tagName;if(!p)return%20%22%22;if(!t)return%20A(p,g);var%20T=t.toUpperCase(),b=(T!=%22TABLE%22&&T!=%22TBODY%22&&T!=%22THEAD%22&&T!=%22TR%22),c=n.className,i=n.id;return%20A(p,'%20%3E%20')+(b?T:T.toLowerCase())+(c?%22.%22+c:%22%22)+(i?%22#%22+i:%22%22)+(b?g:'%20');}document.onmouseover=function(e){e=e?e:event;var%20s,g=e.target;g=g?g:e.srcElement;try{s=A(g,'')+%22%20(click%20for%20computed%20styles)%22;}catch(err){s=err.message;}window.status=s;return%20true;};window.status=A(document.documentElement,'');var%20newSS,styles='*%20{%20cursor:%20crosshair;%20}';newSS=document.createElement('link');newSS.rel='stylesheet';newSS.type='text/css';newSS.href='data:text/css,'+escape(styles);document.getElementsByTagName(%22head%22)[0].appendChild(newSS);document.onclick=function(e){e=e?e:event;var%20s,g=e.target;g=g?g:e.srcElement;var%20x=window.open('','computedStyles');x.document.open();x.document.close();var%20d=x.document;x.onunload=function(){document.onclick=null;document.onmouseover=null;window.status=null;newSS.href='data:text/css,';};function%20sp(n,t,col){var%20r=d.createElement(n);r.appendChild(d.createTextNode(t));if(col)r.style.color=col;return%20r;}var%20typeIndex={'top':1,'bottom':1,'height':1,'width':1,'left':1,'right':1,'position':0,'display':0,'-moz-appearance':0,'-moz-box-sizing':0};var%20colors=[%22red%22,%22green%22,%22black%22];function%20undirect(v){return%20v.replace(/\-(left|top|bottom|right)/,%22-*%22);}function%20diff(n,p){pcs=p.ownerDocument.defaultView.getComputedStyle(p,%22%22);ncs=n.ownerDocument.defaultView.getComputedStyle(n,%22%22);var%20A=[];var%20B={};var%20C={};for(var%20i=0;i%3Cncs.length;++i){var%20e=ncs.item(i),v=ncs.getPropertyValue(e),pv=pcs.getPropertyValue(e);if(v!=pv){var%20u=undirect(e);if(u.indexOf(%22-*%22)!=-1){if(!B[u])B[u]=[0,v];if(B[u][1]==v)++(B[u][0]);}A.push([typeIndex[e]!=null?typeIndex[e]:2,e,v]);}}A=A.sort();for(var%20u%20in%20B)if(B[u][0]==4)C[u]=true;for(var%20i%20in%20A){var%20t=A[i],e=t[1],v=t[2],u=undirect(e);if(C[u]){if(t[1].indexOf(%22-left%22)!=-1)d.body.appendChild(sp(%22div%22,u+%22:%20%22+v,colors[t[0]]));}else%20d.body.appendChild(sp(%22div%22,e+%22:%20%22+v,colors[t[0]]));}}function%20info(n){if(!n)return;if(n.tagName){d.body.appendChild(sp(%22h4%22,A(n,'')));diff(n,n.parentNode.nodeType!='9'?n.parentNode:d.documentElement);}info(n.parentNode);}d.body.appendChild(sp(%22p%22,%22This%20shows%20how%20the%20computed%20style%20of%20each%20node%20differs%20from%20the%20computed%20style%20of%20its%20parent.%20The%20root%20element,%20which%20has%20no%20parent,%20is%20instead%20compared%20against%20the%20root%20of%20a%20blank%20HTML%20document.%22));info(g);x.focus();e.preventDefault();}})()

Убрать все CSS со страницы

javascript:(function(){var%20i,x;for(i=0;x=document.styleSheets[i];++i)x.disabled=true;})();

Аналогично, но с картинками
javascript:(function(){function%20toArray%20(c){var%20a,%20k;a=new%20Array;for%20(k=0;%20k%20%3C%20c.length;%20++k)a[k]=c[k];return%20a;}var%20images,%20img,%20altText;images=toArray(document.images);for%20(var%20i=0;%20i%20%3C%20images.length;%20++i){img=images[i];altText=document.createTextNode(img.alt);img.parentNode.replaceChild(altText,%20img)}})();

Просмотреть все CSS со страницы в одном окне
javascript:s=document.getElementsByTagName('STYLE');%20ex=document.getElementsByTagName('LINK');%20d=window.open().document;%20/*set%20base%20href*/d.open();d.close();%20b=d.body;%20function%20trim(s){return%20s.replace(/^\s*\n/,%20'').replace(/\s*$/,%20'');%20};%20function%20iff(a,b,c){return%20b?a+b+c:'';}function%20add(h){b.appendChild(h);}%20function%20makeTag(t){return%20d.createElement(t);}%20function%20makeText(tag,text){t=makeTag(tag);t.appendChild(d.createTextNode(text));%20return%20t;}%20add(makeText('style',%20'iframe{width:100%;height:18em;border:1px%20solid;'));%20add(makeText('h3',%20d.title='Style%20sheets%20in%20'%20+%20location.href));%20for(i=0;%20i%3Cs.length;%20++i)%20{%20add(makeText('h4','Inline%20style%20sheet'%20%20+%20iff('%20title=%22',s[i].title,'%22')));%20add(makeText('pre',%20trim(s[i].innerHTML)));%20}%20for%20(i=0;%20i%3Cex.length;%20++i)%20{%20rs=ex[i].rel.split('%20');%20for(j=0;j%3Crs.length;++j)%20if%20(rs[j].toLowerCase()=='stylesheet')%20{%20add(makeText('h4','link%20rel=%22'%20+%20ex[i].rel%20+%20'%22%20href=%22'%20+%20ex[i].href%20+%20'%22'%20+%20iff('%20title=%22',ex[i].title,'%22')));%20iframe=makeTag('iframe');%20iframe.src=ex[i].href;%20add(iframe);%20break;%20}%20}%20void%200

Аналогично с JavaScript
javascript:s=document.getElementsByTagName('SCRIPT');%20d=window.open().document;%20/*140681*/d.open();d.close();%20b=d.body;%20function%20trim(s){return%20s.replace(/^\s*\n/,%20'').replace(/\s*$/,%20'');%20};%20function%20add(h){b.appendChild(h);}%20function%20makeTag(t){return%20d.createElement(t);}%20function%20makeText(tag,text){t=makeTag(tag);t.appendChild(d.createTextNode(text));%20return%20t;}%20add(makeText('style',%20'iframe{width:100%;height:18em;border:1px%20solid;'));%20add(makeText('h3',%20d.title='Scripts%20in%20'%20+%20location.href));%20for(i=0;%20i%3Cs.length;%20++i)%20{%20if%20(s[i].src)%20{%20add(makeText('h4','script%20src=%22'%20+%20s[i].src%20+%20'%22'));%20iframe=makeTag('iframe');%20iframe.src=s[i].src;%20add(iframe);%20}%20else%20{%20add(makeText('h4','Inline%20script'));%20add(makeText('pre',%20trim(s[i].innerHTML)));%20}%20}%20void%200

Незаменимый скриптлет для JS-разработчика. Просмотр всех переменных JavaScript

javascript:(function(){var%20x,d,i,v,st;%20x=open();%20d=x.document;%20d.open();%20function%20hE(s){s=s.replace(/&/g,%22&%22);s=s.replace(/%3E/g,%22>%22);s=s.replace(/%3C/g,%22<%22);return%20s;}%20d.write(%22%3Cstyle%3Etd{vertical-align:top;%20white-space:pre;%20}%20table,td,th%20{%20border:%201px%20solid%20#ccc;%20}%20div.er%20{%20color:red%20}%3C/style%3E%3Ctable%20border=1%3E%3Cthead%3E%3Ctr%3E%3Cth%3EVariable%3C/th%3E%3Cth%3EType%3C/th%3E%3Cth%3EValue%20as%20string%3C/th%3E%3C/tr%3E%3C/thead%3E%22);%20for%20(i%20in%20window)%20{%20if%20(!(i%20in%20x)%20)%20{%20v=window[i];%20d.write(%22%3Ctr%3E%3Ctd%3E%22%20+%20hE(i)%20+%20%22%3C/td%3E%3Ctd%3E%22%20+%20hE(typeof(window[i]))%20+%20%22%3C/td%3E%3Ctd%3E%22);%20if%20(v===null)%20d.write(%22null%22);%20else%20if%20(v===undefined)%20d.write(%22undefined%22);%20else%20try{st=v.toString();%20if%20(st.length)d.write(hE(v.toString()));%20else%20d.write(%22 %22)}catch(er){d.write(%22%3Cdiv%20class=er%3E%22+hE(er.toString())+%22%3C/div%3E%22)};%20d.write(%22%3C/pre%3E%3C/td%3E%3C/tr%3E%22);%20}%20}%20d.write(%22%3C/table%3E%22);%20d.close();%20})();

Посмотреть сгенерированный HTML-код

javascript:(function(){%20function%20htmlEscape(s){s=s.replace(/&/g,'&');s=s.replace(/%3E/g,'>');s=s.replace(/%3C/g,'<');return%20s;}%20x=window.open();%20x.document.write('%3Cpre%3E'%20+%20htmlEscape('%3Chtml%3E\n'%20+%20document.documentElement.innerHTML%20+%20'\n%3C/html%3E'));%20x.document.close();%20})();

Аналог функции FireFox. Код выделеного фрагмента.

javascript:function%20getSelSource()%20{%20x%20=%20document.createElement(%22div%22);%20x.appendChild(window.getSelection().getRangeAt(0).cloneContents());%20return%20x.innerHTML;%20}%20function%20makeHR()%20{%20return%20nd.createElement(%22hr%22);%20}%20function%20makeParagraph(text)%20{%20p%20=%20nd.createElement(%22p%22);%20p.appendChild(nd.createTextNode(text));%20return%20p;%20}%20function%20makePre(text)%20{%20p%20=%20nd.createElement(%22pre%22);%20p.appendChild(nd.createTextNode(text));%20return%20p;%20}%20nd%20=%20window.open().document;%20ndb%20=%20nd.body;%20if%20(!window.getSelection%20||%20!window.getSelection().rangeCount%20||%20window.getSelection().getRangeAt(0).collapsed)%20{%20nd.title=%22Generated%20Source%20of:%20%22%20+%20location.href;%20ndb.appendChild(makeParagraph(%22No%20selection,%20showing%20generated%20source%20of%20entire%20document.%22));%20ndb.appendChild(makeHR());%20ndb.appendChild(makePre(%22%3Chtml%3E\n%22%20+%20document.documentElement.innerHTML%20+%20%22\n%3C/html%3E%22));%20}%20else%20{%20nd.title=%22Partial%20Source%20of:%20%22%20+%20location.href;%20ndb.appendChild(makePre(getSelSource()));%20};%20void%200

Выделить бордеры всех DIV-ов

javascript:(function(){var%20newSS;%20newSS=document.createElement(%22link%22);%20newSS.rel=%22stylesheet%22;%20newSS.type=%22text/css%22;%20newSS.href%20=%20%22http://www.cs.hmc.edu/~jruderma/block-structure.css%22;%20document.getElementsByTagName(%22head%22)[0].appendChild(newSS);%20})();

Выводим alert при возникновении ошибки

javascript:window.onerror%20=%20function(m,u,n)%20{%20alert(%22JS%20error:%20%22%20+%20m%20+%20(/^javascript:/(u)%20?%20%22\n\n(bookmarklet)%22%20:%20%22\n\nLine%20%22%20+%20n%20+%20%22%20of%20\n%22%20+%20u));%20return%20true;/*suppress%20default%20error%20message*/%20};%20void%200

Обещаный подарок


Я понимаю, что популярность ВКонтакте на Хабре падает, но тем не менее ВКонтакте отличный поисковик музыки. Но смотреть что там он скачивает через FireBug или Cmd+Shift+A (Safari) неудобно. Иногда хочется скачать песню сразу, как только увидел ее на странице друга.
Для этих целей и был сделан этот скриптлет.

javascript:%20var%20elems%20=%20document.getElementsByTagName('td');for(var%20i=0;%20i<elems.length;%20i++){if(elems[i].innerHTML.indexOf('playimg')>0){params%20=%20elems[i].innerHTML.split('%20');params[4]=params[4].split('operate(').join('');params[4]=params[4].split(');"').join('');params[4]=params[4].split("'").join('');%20params%20=%20params[4].split(',');href%20=%20'http://cs'+params[1]+'.vkontakte.ru/u'+params[2]+'/audio/'+params[3]+'.mp3';elems[i].innerHTML=elems[i].innerHTML+'<a%20href="'+href+'"%20target="new">%D0%A1%D0%BA%D0%B0%D1%87%D0%B0%D1%82%D1%8C';}}void(null)

Данный скриптлет был написан моим другом. На Хабре его зовут snetgrom.

ЗЫ Еще раз прошу прощения за месиво кода на странице, но в ссылки его вставить не удалось. Парсер «Jevix» все это режет.

UPD

Google-ориентированные скриптлеты



Добавление выделеного текста в Google.Notepad

javascript:(function()%7Bvar%20w=window;var%20d=document;var%20g=w.open('about:blank','gnotesWin','location=0,menubar=0,scrollbars=0,status=0,toolbar=0,width=300,height=300,resizable');var%20s=d.createElement('script');s.setAttribute('src','http://www.google.com/notebook/bookmarkletPoster%3Fzx='+(new%20Date()).valueOf());d.body.appendChild(s);w.setTimeout(function()%7Bw.blur();g.focus();%7D,%20100)%7D).call(%7B%7D);


Добавление ссылки в Google.Bookmarks

javascript:location.href='http://www.google.com/bookmarks/mark?op=add&bkmk='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title)

Добавление ленты в Google.Reader

javascript:var%20b=document.body;var%20GR________bookmarklet_domain='http://www.google.com';if(b&&!document.xmlVersion){void(z=document.createElement('script'));void(z.src='http://www.google.com/reader/ui/subscribe-bookmarklet.js');void(b.appendChild(z));}else{location='http://www.google.com/reader/view/feed/'+encodeURIComponent(location.href)}


UPD Это все кросс пост из моего блога.

К сожалению я так и не смог заставить WordPress запостить такие длинные ссылки, но я все обрамил тегами CODE и все стало достатчно симпатично.
Tags:
Hubs:
+100
Comments 44
Comments Comments 44

Articles