index.html 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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>Execute javascript codes</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">Execute javascript codes
  38. <br>
  39. <span class="subtitle"></span>
  40. </h1>
  41. <ul class="tags">
  42. </ul>
  43. <p><a href="../sitejs/index.html#">javascript for domains</a><br>
  44. <a href="../globalcss/index.html#">Earliest loaded global javascript</a> files locates in the subfolder &quot;css&quot; of app private folder.</p>
  45. <p><b>Global javascript</b> files locates in the subfolder &quot;js&quot; of app private folder. Long press button [☰] to configure. Click the following links to install:<br>
  46. <a target="_self" href="i:0hjs/savePassword.js:../../zh/searchurl/txt/passwdsave.js">Save password</a><br>
  47. <a target="_self" href="i:0hjs/instantPage.js:https://fastly.jsdelivr.net/npm/instant.page">Instant page</a></p>
  48. <p><b>large size javascript code</b> can be installed to the folder &quot;bookmarklet&quot; (long pressing button &quot;js&quot; to popup menu):<br>
  49. <a target="_self" href="i:0hbookmarklet/!googleTranslate.js:https://translate.google.com/translate_a/element.js?cb=googleTranslateElementInit:%0A{let d=document,b=d.body,v=d.createElement('div');v.id='google_translate_element';v.style='position:fixed;bottom:10px;right:10px;cursor:pointer;z-index:9999';b.insertBefore(v,b.firstChild);function googleTranslateElementInit(){new google.translate.TranslateElement({layout:google.translate.TranslateElement.InlineLayout.SIMPLE,multilanguagePage:true,pageLanguage:'auto',includedLanguages:'zh-CN,zh-TW,en,ko,ja'},'google_translate_element');}}">google translation</a></p>
  50. <p><a target="_self" href='i:0hbookmarklet/eruda.js:https://fastly.jsdelivr.net/npm/eruda:%0Aeruda.init()'>Eruda</a><br>
  51. <a target="_self" href="i:0hbookmarklet/performance.js:https://fastly.jsdelivr.net/gh/micmro/performance-bookmarklet/dist/performanceBookmarklet.min.js">Performance</a></p>
  52. <p>Note: Bookmarklets whose names begin with &quot;!&quot; are allowed to load remote js on CSP (Content Security Policy) sites.</p>
  53. <p><b>Remote javascript</b> is defined in default.rjs. Click the following link to install. (<b>Force exit and re-launch the app</b>, then long press the &quot;search&quot; button to popup the menu.):</p>
  54. <p><a href="i:04Selection to sentence:;let g='sentence';getSelection().modify('move','forward',g);getSelection().modify('extend','backward',g);">Selection to sentence:;let g='sentence';getSelection().modify('move','forward',g);getSelection().modify('extend','backward',g);</a></p>
  55. <p><a href="i:04Selection to line:;let g='line';getSelection().modify('move','forward',g);getSelection().modify('extend','backward',g);">Selection to line:;let g='line';getSelection().modify('move','forward',g);getSelection().modify('extend','backward',g);</a></p>
  56. <p><a href="i:04Selection to paragraph:;let g='paragraph';getSelection().modify('move','forward',g);getSelection().modify('extend','backward',g);">Selection to paragraph:;let g='paragraph';getSelection().modify('move','forward',g);getSelection().modify('extend','backward',g);</a></p>
  57. <p><a href="i:04markdown:['https://cdn.jsdelivr.net/npm/showdown/dist/showdown.min.js'];var d=document;var md=d.querySelector('pre').innerText;var c=new showdown.Converter({emoji:true,underline:true,});c.setFlavor('github');d.body.innerHTML=c.makeHtml(md);d.title=d.title||d.body.firstElementChild.innerText.trim();">markdown:['https://cdn.jsdelivr.net/npm/showdown/dist/showdown.min.js'];var d=document;var md=d.querySelector('pre').innerText;var c=new showdown.Converter({emoji:true,underline:true,});c.setFlavor('github');d.body.innerHTML=c.makeHtml(md);d.title=d.title||d.body.firstElementChild.innerText.trim();</a></p>
  58. <p><a href="i:04mermaid:;loadModuleJS(`import mermaid from 'https://unpkg.com/mermaid/dist/mermaid.esm.min.mjs';mermaid.initialize({startOnLoad:true});`)">mermaid:;loadModuleJS(<code>import mermaid from 'https://unpkg.com/mermaid/dist/mermaid.esm.min.mjs';mermaid.initialize({startOnLoad:true});</code>)</a></p>
  59. <p><a href="i:04mathjax:['https://fastly.jsdelivr.net/npm/mathjax@3/es5/tex-svg.js']">mathjax:['https://fastly.jsdelivr.net/npm/mathjax@3/es5/tex-svg.js']</a></p>
  60. <p><a href="i:04New tab to open links:;let d=document;b=d.createElement('base');b.setAttribute('target','_blank');d.head.appendChild(b)">New tab to open links:;let d=document;b=d.createElement('base');b.setAttribute('target','_blank');d.head.appendChild(b)</a></p>
  61. <p><a href="i:04Site search:;open('i:15site:' + location.hostname)">Site search:;open('i:15site:' + location.hostname)</a></p>
  62. <p><a href="i:04Spell check:;let t=document.getElementsByTagName('textarea');let v=t[0].spellcheck;if(v==null)v=false;t[0].spellcheck=!v">Spell check:;let t=document.getElementsByTagName('textarea');let v=t[0].spellcheck;if(v==null)v=false;t[0].spellcheck=!v</a></p>
  63. <p>Remote script configuration file &quot;default.rjs&quot; whose lines have the following format:<br>
  64. [script name]:[javascript code to return url arrays]</p>
  65. <h4 id="activated-scripts">Activated scripts</h4>
  66. <p>Activate either local (bookmarklets) or remote js to execute the code on the similar sites with option &quot;Activate user script&quot;.</p>
  67. <p>Since activated scripts use internal mechanism of <a href="../links/index.html#">&quot;i:0m&quot; urls</a>, the script itself cannot have <span style="color:red">'H', '?' or '/'</span> as its very first character.</p>
  68. <h4 id="allow-remote-js-on-csp-content-security-policy-sites">Allow remote js on CSP (Content Security Policy) sites</h4>
  69. <p>All remote js (default.rjs) are allowed to execute on CSP sites. Local js files without remote resource access work fine when under the folder &quot;bookmarklet&quot;, others needs to be refered in default.rjs as http urls such as &quot;https://local/...&quot; (<a href="../html5/index.html#">html5</a> or <a href="../offlinecache/index.html#">offline cache</a>) .</p>
  70. </div>
  71. <p>Last Modified: 8 April 2024<br>
  72. fix typos<br>
  73. <pre></pre>
  74. </p>
  75. <script id='jsgiscus'
  76. src='https://giscus.app/client.js'
  77. data-repo="torappinfo/uweb"
  78. data-repo-id="MDEwOlJlcG9zaXRvcnkzMDIyMDU3MjE="
  79. data-category="Announcements"
  80. data-category-id="DIC_kwDOEgNLGc4CQjsh"
  81. data-mapping="title"
  82. data-strict="0"
  83. data-reactions-enabled="1"
  84. data-emit-metadata="0"
  85. data-input-position="top"
  86. data-theme="light"
  87. data-lang="en"
  88. data-loading="lazy"
  89. crossorigin="anonymous" async>
  90. </script>
  91. <footer class="site-footer">
  92. <div class="container">
  93. &copy; 2018-2024 Richard H. Cao
  94. </div>
  95. </footer>
  96. <!-- 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/>. -->
  97. </body>
  98. </html>