index.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1" />
  6. <link rel="stylesheet" href="../style.css#" type="text/css" />
  7. <title>Bookmarklets</title>
  8. <script type="text/javascript">
  9. function findLang(){
  10. let href = location.href;
  11. for(let i=href.length-1;i>0;i--){
  12. if('/'==href.charAt(i) && '/'==href.charAt(i-3))
  13. return i;
  14. }
  15. return 0;
  16. }
  17. function nav2(page){
  18. let i = findLang();
  19. location.href = location.href.substring(0,i+1)+page;
  20. }
  21. function nav2Lang(lang){
  22. let i = findLang();
  23. let href = location.href;
  24. location.href = location.href.substring(0,i-2)+lang+location.href.substring(i);
  25. }
  26. </script>
  27. </head>
  28. <body>
  29. <header class='header'>
  30. <a class="logo" href="javascript:void(0)" onclick="return nav2('index.html#')">Home</a> <a class="logo" href="javascript:void(0)" onclick="return nav2('tags/index.html#')">Tags</a>
  31. <a class="logo" href="javascript:void(0)" onclick="return nav2Lang('zh')">简体中文</a>
  32. <nav>
  33. </nav>
  34. </header>
  35. <br />
  36. <div class="container">
  37. <h1 class="title">Bookmarklets
  38. <br>
  39. <span class="subtitle"></span>
  40. </h1>
  41. <ul class="tags">
  42. <li><a href="../tags/javascript/index.html#">javascript</a> </li>
  43. </ul>
  44. <p>With <a href="../index.html#">uweb browser</a>, long pressing any bookmarklet link, click &quot;Open in new tab&quot;, the bookmarklet will be run on the last other tab.</p>
  45. <p><a href="javascript:{let es=document.getElementsByTagName('script');let urls='';for(let i=0;i<es.length;i++){if(es[i].src)urls+=es[i].src+'<br>';}let w=window.open(''),s=w.document;s.write(urls);s.close();w.location.href='i:631:';}">List all script urls</a></p>
  46. <p><a target="_self" href="javascript:alert(navigator.userAgent)">User agent</a><br>
  47. <a href="javascript:(function(){var w=window.open(''),s=w.document;s.write('<html><body></body></html>');s.close();var pre=s.body.appendChild(s.createElement('pre'));pre.style.overflow='auto';pre.style.whiteSpace='pre-wrap';pre.appendChild(s.createTextNode(document.cookie))})()">Cookie</a><br>
  48. <a href="javascript:(function(){var w=window.open(''),s=w.document;s.write('<html><body></body></html>');s.close();var pre=s.body.appendChild(s.createElement('pre'));pre.style.overflow='auto';pre.style.whiteSpace='pre-wrap';pre.appendChild(s.createTextNode(document.documentElement.innerHTML))})()">Source code</a><br>
  49. <a href="javascript:function%20gett(w){try{var%20lm=new%20Date(w.document.lastModified);if(lm>maxd)maxd=lm;for(var%20i=0;F=w.frames[i];i++){gett(F);}}catch(e){}}var%20now=new%20Date();var%20maxd=new%20Date(document.lastModified);gett(window);if(maxd.getTime()==0||now.toUTCString()==maxd.toUTCString()){alert('Page%20is%20dynamically%20generated,%20cannot%20determine%20date.');}else{alert('Page%20was%20last%20modified%20'+maxd.toLocaleString());}" class="bookmarklet" rel="nofollow">Last modified date</a></p>
  50. <p><a href="javascript:(function(){var script=document.createElement('script');script.src='//fastly.jsdelivr.net/npm/eruda';document.body.appendChild(script);script.onload=function(){eruda.init()}})()">Eruda: mobile console</a><br>
  51. <a href="javascript:window.open('https://api.qrserver.com/v1/create-qr-code/?size=150x150&data='%20+%20decodeURIComponent(location.href));void(0);">QR code generation</a></p>
  52. <p><a href="javascript:(function(){var x,i; x = document.forms; for (i = 0; i &lt; x.length; ++i) x[i].method=&quot;get&quot;; alert(&quot;Changed &quot; + x.length + &quot; forms to use the GET method. After submitting a form from this page, you should be able to bookmark the result.&quot;); })();">Use &quot;GET&quot; method for &quot;POST&quot;</a><br>
  53. <a href="javascript:(function(){var i,f,j,e,div,label,ne; for(i=0;f=document.forms[i];++i)for(j=0;e=f[j];++j)if(e.type==&quot;hidden&quot;){ D=document; function C(t){return D.createElement(t);} function A(a,b){a.appendChild(b);} div=C(&quot;div&quot;); label=C(&quot;label&quot;); A(div, label); A(label, D.createTextNode(e.name + &quot;: &quot;)); e.parentNode.insertBefore(div, e); e.parentNode.removeChild(e); ne=C(&quot;input&quot;);/*for ie*/ ne.type=&quot;text&quot;; ne.value=e.value; A(label, ne); --j;}})()">Shows all form elements</a><br>
  54. <a href="javascript:(function(){var x,k,f,j;x=document.forms;for (k=0;k&lt;x.length;++k){f=x[k];for(j=0;j&lt;f.length;++j){f[j].disabled=false; f[j].readOnly=false;}}})()">Enables all form elements</a></p>
  55. <p><a href="javascript:(function(){function toggle(box){temp=box.onchange;box.onchange=null;box.checked=!box.checked;box.onchange=temp;}var f=document.querySelectorAll(%22input[type='checkbox']%22);var j;for(j=0;j<f.length;++j)toggle(f[j]);})()">Toggle checkboxes</a><br>
  56. <a href="javascript:(function(){function set(box,bChecked){temp=box.onchange;box.onchange=null;box.checked=bChecked;box.onchange=temp;}var f=document.querySelectorAll(%22input[type='checkbox']%22);var j;for(j=0;j<f.length;++j)set(f[j],true);})()">Check all checkboxes</a><br>
  57. <a href="javascript:(function(){function set(box,bChecked){temp=box.onchange;box.onchange=null;box.checked=bChecked;box.onchange=temp;}var f=document.querySelectorAll(%22input[type='checkbox']%22);var j;for(j=0;j<f.length;++j)set(f[j],false);})()">Uncheck all checkboxes</a><br>
  58. <a href="javascript:(function(){ function toggle(box){ temp=box.onchange; box.onchange=null; box.checked=!box.checked; box.onchange=temp; } var x,k,f,j; x=document.forms; for (k=0; k<x.length; ++k) { f=x[k]; for (j=0;j<f.length;++j) if (f[j].type.toLowerCase() == &quot;checkbox&quot;) toggle(f[j]); } })();">Toggle all checkboxes in forms</a><br>
  59. <a href="javascript:(function(){var%20doc=document;var%20bd=doc.body;bd.onselectstart=bd.oncopy=bd.onpaste=bd.onkeydown=bd.oncontextmenu=bd.onmousemove=bd.onselectstart=bd.ondragstart=doc.onselectstart=doc.oncopy=doc.onpaste=doc.onkeydown=doc.oncontextmenu=null;doc.onselectstart=doc.oncontextmenu=doc.onmousedown=doc.onkeydown=null;void(0)})()">Enable selection</a><br>
  60. <a href="javascript:(function() { function R(a){ona = &quot;on&quot;+a; if(window.addEventListener) window.addEventListener(a, function (e) { for(var n=e.originalTarget; n; n=n.parentNode) n[ona]=null; }, true); window[ona]=null; document[ona]=null; if(document.body) document.body[ona]=null; } R(&quot;contextmenu&quot;); R(&quot;click&quot;); R(&quot;mousedown&quot;); R(&quot;mouseup&quot;); })()">Restore context menu</a><br>
  61. <a href="javascript:(function(){var count=0, text, regexp;text=prompt(&quot;Search regexp:&quot;, &quot;&quot;);if(text==null || text.length==0)return;try{regexp=new RegExp(&quot;(&quot; + text +&quot;)&quot;, &quot;i&quot;);}catch(er){alert(&quot;Unable to create regular expression using text '&quot;+text+&quot;'.\n\n&quot;+er);return;}function searchWithinNode(node, re){var pos, skip, spannode, middlebit, endbit, middleclone;skip=0;if( node.nodeType==3 ){pos=node.data.search(re);if(pos>=0){spannode=document.createElement(&quot;SPAN&quot;);spannode.style.backgroundColor=&quot;yellow&quot;;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 if( node.nodeType==1 &amp;&amp; node.childNodes &amp;&amp; node.tagName.toUpperCase()!=&quot;SCRIPT&quot; &amp;&amp; node.tagName.toUpperCase!=&quot;STYLE&quot;){for (var child=0; child < node.childNodes.length; ++child){child=child+searchWithinNode(node.childNodes[child], re);}}return skip;}window.status=&quot;Searching for &quot;+regexp+&quot;...&quot;;searchWithinNode(document.body, regexp);window.status=&quot;Found &quot;+count+&quot; match&quot;+(count==1?&quot;&quot;:&quot;es&quot;)+&quot; for &quot;+regexp+&quot;.&quot;;})();">Search with regex</a><br>
  62. <a href="javascript:function toArray (c){var a, k;a=new Array;for (k=0; k<c.length; ++k)a[k]=c[k];return a;}function insAtTop(par,child){if(par.childNodes.length) par.insertBefore(child, par.childNodes[0]);else par.appendChild(child);}function countCols(tab){var nCols, i;nCols=0;for(i=0;i<tab.rows.length;++i)if(tab.rows[i].cells.length>nCols)nCols=tab.rows[i].cells.length;return nCols;}function makeHeaderLink(tableNo, colNo, ord){var link;link=document.createElement('a');link.href='javascript:sortTable('+tableNo+','+colNo+','+ord+');';link.appendChild(document.createTextNode((ord>0)?'a':'d'));return link;}function makeHeader(tableNo,nCols){var header, headerCell, i;header=document.createElement('tr');for(i=0;i<nCols;++i){headerCell=document.createElement('td');headerCell.appendChild(makeHeaderLink(tableNo,i,1));headerCell.appendChild(document.createTextNode('/'));headerCell.appendChild(makeHeaderLink(tableNo,i,-1));header.appendChild(headerCell);}return header;}g_tables=toArray(document.getElementsByTagName('table'));if(!g_tables.length) alert(&quot;This page doesn't contain any tables.&quot;);(function(){var j, thead;for(j=0;j<g_tables.length;++j){thead=g_tables[j].createTHead();insAtTop(thead, makeHeader(j,countCols(g_tables[j])))}}) ();function compareRows(a,b){if(a.sortKey==b.sortKey)return 0;return (a.sortKey < b.sortKey) ? g_order : -g_order;}function sortTable(tableNo, colNo, ord){var table, rows, nR, bs, i, j, temp;g_order=ord;g_colNo=colNo;table=g_tables[tableNo];rows=new Array();nR=0;bs=table.tBodies;for(i=0; i<bs.length; ++i)for(j=0; j<bs[i].rows.length; ++j){rows[nR]=bs[i].rows[j];temp=rows[nR].cells[g_colNo];if(temp) rows[nR].sortKey=temp.innerHTML;else rows[nR].sortKey=&quot;&quot;;++nR;}rows.sort(compareRows);for (i=0; i < rows.length; ++i)insAtTop(table.tBodies[0], rows[i]);}">Table re-order</a></p>
  63. <p><a href="javascript: (function() { var url = ('http://www.bugmenot.com/view/' + escape(location.hostname)); w = open(url, 'w', 'location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=500,height=400,modal=yes,dependent=yes'); if (w) { setTimeout('w.focus()', 1000) } else { location = url } })();">BugMeNot</a></p>
  64. </div>
  65. <p>Last Modified: 11 June 2024<br>
  66. fix typos<br>
  67. <pre></pre>
  68. </p>
  69. <script id='jsgiscus'
  70. src='https://giscus.app/client.js'
  71. data-repo="torappinfo/uweb"
  72. data-repo-id="MDEwOlJlcG9zaXRvcnkzMDIyMDU3MjE="
  73. data-category="Announcements"
  74. data-category-id="DIC_kwDOEgNLGc4CQjsh"
  75. data-mapping="title"
  76. data-strict="0"
  77. data-reactions-enabled="1"
  78. data-emit-metadata="0"
  79. data-input-position="top"
  80. data-theme="light"
  81. data-lang="en"
  82. data-loading="lazy"
  83. crossorigin="anonymous" async>
  84. </script>
  85. <footer class="site-footer">
  86. <div class="container">
  87. &copy; 2018-2024 Richard H. Cao
  88. </div>
  89. </footer>
  90. <!-- This document is licensed under the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is available at <https://www.gnu.org/licenses/>. -->
  91. </body>
  92. </html>