<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Javascript on uweb browser: unlimited power</title>
    <link>/en/tags/javascript/</link>
    <description>Recent content in Javascript on uweb browser: unlimited power</description>
    <generator>Hugo</generator>
    <language>en</language>
    <lastBuildDate>Tue, 11 Jun 2024 08:12:27 +0800</lastBuildDate>
    <atom:link href="/en/tags/javascript/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>JS/CSS/HTML/preprocessing for domains</title>
      <link>/en/sitejs/</link>
      <pubDate>Sat, 28 Jan 2023 00:00:00 +0000</pubDate>
      <guid>/en/sitejs/</guid>
      <description>&lt;h3 id=&#34;javascript-load-when-page-completes-earliest-loaded-js-should-use-sitecss&#34;&gt;Javascript (load when page completes, earliest loaded JS should use sitecss).&lt;/h3&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Need to be named as &amp;quot;[domain root].js&amp;quot;, such as &amp;quot;yahoo.com.js&amp;quot; or &amp;quot;finance.yahoo.com.js&amp;quot;. The script will be loaded on the whole domain tree sites. If several files matches the domain, then the script with longest file name is loaded.&lt;/li&gt;&#xA;&lt;li&gt;Script must be put under the folder &amp;quot;sitejs&amp;quot; or &amp;quot;/data/data/info.torapp.uweb/files/sitejs&amp;quot;. The later folder has the priority.&lt;/li&gt;&#xA;&lt;li&gt;Long press the button &amp;quot;settings&amp;quot;, check the option &amp;quot;Run user scripts&amp;quot;.&lt;/li&gt;&#xA;&lt;li&gt;Support 2/3-segment domains. If the length of the last 2-segments of domain is less than 7 (ex. &amp;quot;com.pl&amp;quot;), then it is treated as one segment.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h3 id=&#34;css-style-and-earliest-loaded-js&#34;&gt;CSS style and earliest loaded JS&lt;/h3&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Need to be named as &amp;quot;[domain root].css&amp;quot;, such as yahoo.com.css or finance.yahoo.com.css。&lt;/li&gt;&#xA;&lt;li&gt;Under folder &amp;quot;sitecss&amp;quot;.&lt;/li&gt;&#xA;&lt;li&gt;&amp;quot;[domain root].js&amp;quot; is loaded at the earliest time.&lt;/li&gt;&#xA;&lt;li&gt;Long press the button &amp;quot;settings&amp;quot;, check the option &amp;quot;Apply user styles&amp;quot;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;If file &amp;quot;default.css&amp;quot; exists, the style will be applied to all sites not matching [domain root].css.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Bookmarklets</title>
      <link>/en/bookmarklet/</link>
      <pubDate>Fri, 24 Jun 2022 00:00:00 +0000</pubDate>
      <guid>/en/bookmarklet/</guid>
      <description>&lt;p&gt;With &lt;a href=&#34;../index.html#&#34;&gt;uweb browser&lt;/a&gt;, long pressing any bookmarklet link, click &amp;quot;Open in new tab&amp;quot;, the bookmarklet will be run on the last other tab.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&#34;javascript:{let es=document.getElementsByTagName(&#39;script&#39;);let urls=&#39;&#39;;for(let i=0;i&lt;es.length;i++){if(es[i].src)urls+=es[i].src+&#39;&lt;br&gt;&#39;;}let w=window.open(&#39;&#39;),s=w.document;s.write(urls);s.close();w.location.href=&#39;i:631:&#39;;}&#34;&gt;List all script urls&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a target=&#34;_self&#34; href=&#34;javascript:alert(navigator.userAgent)&#34;&gt;User agent&lt;/a&gt;&lt;br&gt;&#xA;&lt;a href=&#34;javascript:(function(){var w=window.open(&#39;&#39;),s=w.document;s.write(&#39;&lt;html&gt;&lt;body&gt;&lt;/body&gt;&lt;/html&gt;&#39;);s.close();var pre=s.body.appendChild(s.createElement(&#39;pre&#39;));pre.style.overflow=&#39;auto&#39;;pre.style.whiteSpace=&#39;pre-wrap&#39;;pre.appendChild(s.createTextNode(document.cookie))})()&#34;&gt;Cookie&lt;/a&gt;&lt;br&gt;&#xA;&lt;a href=&#34;javascript:(function(){var w=window.open(&#39;&#39;),s=w.document;s.write(&#39;&lt;html&gt;&lt;body&gt;&lt;/body&gt;&lt;/html&gt;&#39;);s.close();var pre=s.body.appendChild(s.createElement(&#39;pre&#39;));pre.style.overflow=&#39;auto&#39;;pre.style.whiteSpace=&#39;pre-wrap&#39;;pre.appendChild(s.createTextNode(document.documentElement.innerHTML))})()&#34;&gt;Source code&lt;/a&gt;&lt;br&gt;&#xA;&lt;a href=&#34;javascript:function%20gett(w){try{var%20lm=new%20Date(w.document.lastModified);if(lm&gt;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(&#39;Page%20is%20dynamically%20generated,%20cannot%20determine%20date.&#39;);}else{alert(&#39;Page%20was%20last%20modified%20&#39;+maxd.toLocaleString());}&#34; class=&#34;bookmarklet&#34; rel=&#34;nofollow&#34;&gt;Last modified date&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&#34;javascript:(function(){var script=document.createElement(&#39;script&#39;);script.src=&#39;//fastly.jsdelivr.net/npm/eruda&#39;;document.body.appendChild(script);script.onload=function(){eruda.init()}})()&#34;&gt;Eruda: mobile console&lt;/a&gt;&lt;br&gt;&#xA;&lt;a href=&#34;javascript:window.open(&#39;https://api.qrserver.com/v1/create-qr-code/?size=150x150&amp;data=&#39;%20+%20decodeURIComponent(location.href));void(0);&#34;&gt;QR code generation&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&#34;javascript:(function(){var x,i; x = document.forms; for (i = 0; i &amp;lt; x.length; ++i) x[i].method=&amp;quot;get&amp;quot;; alert(&amp;quot;Changed &amp;quot; + x.length + &amp;quot; forms to use the GET method.  After submitting a form from this page, you should be able to bookmark the result.&amp;quot;); })();&#34;&gt;Use &amp;quot;GET&amp;quot; method for &amp;quot;POST&amp;quot;&lt;/a&gt;&lt;br&gt;&#xA;&lt;a href=&#34;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==&amp;quot;hidden&amp;quot;){ D=document; function C(t){return D.createElement(t);} function A(a,b){a.appendChild(b);} div=C(&amp;quot;div&amp;quot;); label=C(&amp;quot;label&amp;quot;); A(div, label); A(label, D.createTextNode(e.name + &amp;quot;: &amp;quot;)); e.parentNode.insertBefore(div, e); e.parentNode.removeChild(e); ne=C(&amp;quot;input&amp;quot;);/*for ie*/ ne.type=&amp;quot;text&amp;quot;; ne.value=e.value; A(label, ne); --j;}})()&#34;&gt;Shows all form elements&lt;/a&gt;&lt;br&gt;&#xA;&lt;a href=&#34;javascript:(function(){var x,k,f,j;x=document.forms;for (k=0;k&amp;lt;x.length;++k){f=x[k];for(j=0;j&amp;lt;f.length;++j){f[j].disabled=false; f[j].readOnly=false;}}})()&#34;&gt;Enables all form elements&lt;/a&gt;&lt;/p&gt;</description>
    </item>
    <item>
      <title>Long pressed link menu</title>
      <link>/en/longclick/</link>
      <pubDate>Fri, 06 Nov 2020 00:00:00 +0000</pubDate>
      <guid>/en/longclick/</guid>
      <description>&lt;h4 id=&#34;to-run-commands&#34;&gt;To run commands&lt;/h4&gt;&#xA;&lt;p&gt;Each line of file &amp;quot;&lt;a href=&#34;file:///data/data/info.torapp.uweb/files/default.longclick&#34;&gt;default.longclick&lt;/a&gt;&amp;quot; has the following format: (same as &lt;a href=&#34;../cmds/index.html#&#34;&gt;default.cmds&lt;/a&gt;)&lt;br&gt;&#xA;[Name]:[mimetype]:[command line]&lt;br&gt;&#xA;in which [command line] can have &lt;a href=&#34;../cmds/index.html#&#34;&gt;&amp;quot;%c&amp;quot; (cookie), &amp;quot;%u&amp;quot; (current url), &amp;quot;%t&amp;quot; (title)&lt;/a&gt; etc.&lt;/p&gt;&#xA;&lt;h4 id=&#34;to-visit-url-and-load-javascript-file&#34;&gt;To visit url and load javascript file&lt;/h4&gt;&#xA;&lt;p&gt;All &amp;quot;.js&amp;quot; files under the folder &amp;quot;&lt;a href=&#34;file:///data/data/info.torapp.uweb/files/longclick/&#34;&gt;longclick&lt;/a&gt;&amp;quot; are part of the popup menu.&lt;br&gt;&#xA;These javascript files are in the following format:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The very first line can begin with &amp;quot;//&amp;quot; followed by website url that can have &lt;a href=&#34;../cmds/index.html#&#34;&gt;&amp;quot;%u&amp;quot; (current url), &amp;quot;%t&amp;quot; (title)&lt;/a&gt; etc. included. In this case, the website is visited, then the javascript file is loaded on the new loaded site.&lt;/li&gt;&#xA;&lt;li&gt;In the &amp;quot;.js&amp;quot; file, variable &amp;quot;arguments&amp;quot; can be used to get parameters. in which arguments[1] is the long-pressed link url, argument[2] is the text description and arguments[0] is the &amp;quot;.js&amp;quot; file name.&lt;/li&gt;&#xA;&lt;/ul&gt;</description>
    </item>
  </channel>
</rss>
