119 lines
5.6 KiB
HTML
119 lines
5.6 KiB
HTML
<!doctype html>
|
|
<html>
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
<link rel="canonical" href="https://jamesfengcao.gitlab.io/uweb/en/sitejs/" />
|
|
|
|
<link rel="stylesheet" href="../style.css#" type="text/css" />
|
|
<title>JS/CSS/HTML/preprocessing for domains</title>
|
|
<script>
|
|
function findLang(){
|
|
let href = location.href;
|
|
for(let i=href.length-1;i>0;i--){
|
|
if('/'==href.charAt(i) && '/'==href.charAt(i-3))
|
|
return i;
|
|
}
|
|
return 0;
|
|
}
|
|
function nav2(page){
|
|
let i = findLang();
|
|
location.href = location.href.substring(0,i+1)+page;
|
|
}
|
|
function nav2Lang(lang){
|
|
let i = findLang();
|
|
let href = location.href;
|
|
location.href = location.href.substring(0,i-2)+lang+location.href.substring(i);
|
|
}
|
|
</script>
|
|
</head>
|
|
<body>
|
|
<header class='header'>
|
|
<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>
|
|
|
|
|
|
<a class="logo" href="javascript:void(0)" onclick="return nav2Lang('zh')">简体中文</a>
|
|
|
|
|
|
<nav>
|
|
</nav>
|
|
</header>
|
|
<br />
|
|
|
|
<div class="container">
|
|
<h1 class="title">JS/CSS/HTML/preprocessing for domains
|
|
<br>
|
|
<span class="subtitle"></span>
|
|
</h1>
|
|
<ul class="tags">
|
|
|
|
<li><a href="../tags/javascript/index.html#">javascript</a> </li>
|
|
|
|
<li><a href="../tags/css/index.html#">css</a> </li>
|
|
|
|
</ul>
|
|
<h3 id="javascript-load-when-page-completes-earliest-loaded-js-should-use-sitecss">Javascript (load when page completes, earliest loaded JS should use sitecss).</h3>
|
|
<ul>
|
|
<li>Need to be named as "[domain root].js", such as "yahoo.com.js" or "finance.yahoo.com.js". 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.</li>
|
|
<li>Script must be put under the folder "sitejs" or "/data/data/info.torapp.uweb/files/sitejs". The later folder has the priority.</li>
|
|
<li>Long press the button "settings", check the option "Run user scripts".</li>
|
|
<li>Support 2/3-segment domains. If the length of the last 2-segments of domain is less than 7 (ex. "com.pl"), then it is treated as one segment.</li>
|
|
</ul>
|
|
<h3 id="css-style-and-earliest-loaded-js">CSS style and earliest loaded JS</h3>
|
|
<ul>
|
|
<li>Need to be named as "[domain root].css", such as yahoo.com.css or finance.yahoo.com.css。</li>
|
|
<li>Under folder "sitecss".</li>
|
|
<li>"[domain root].js" is loaded at the earliest time.</li>
|
|
<li>Long press the button "settings", check the option "Apply user styles".</li>
|
|
</ul>
|
|
<p>If file "default.css" exists, the style will be applied to all sites not matching [domain root].css.</p>
|
|
<h3 id="preprocessing-or-extra-html">Preprocessing or extra html</h3>
|
|
<ul>
|
|
<li>Need to be named as "[domain].sanitizer" or "[domain].html". Notice: the file name stem here is "[full domain]" not "[domain root]".</li>
|
|
<li>Under folder "siteextra".</li>
|
|
<li>Long press the button "settings", check the option "Apply user extra".</li>
|
|
</ul>
|
|
<h4 id="sanitizer">sanitizer</h4>
|
|
<p>"[domain].sanitizer" is a valid js file with browser sanitizer API configuration. It has priority over "[domain].html". The "sanitizer" is used to sanitize the web page for android webview version 146+.</p>
|
|
<p>Specifically, the first part of "[domain].sanitizer" could be:</p>
|
|
<ul>
|
|
<li>string array of disallowed js scripts, The very first character must be '['. Ex. "['foo.js']".</li>
|
|
<li>browser sanitizer() API configuration options. Ex. "{allowElements: ['p', 'a']}".</li>
|
|
</ul>
|
|
<h4 id="domainhtml">"[domain].html"</h4>
|
|
<p>An open tag as the last tag in the last 50 bytes of the user extra html expects more content to follow, thus the extra html is placed before the site html. Ex. when the extra html ends with "<textarea>" or "<plaintext>", the site source html appears as the value of the textarea/plaintext element, thus the extra html can further process the the site source html before rendering. A self closed tag such as "<br>" acts like open tags, also makes the site source follow the extra html.</p>
|
|
<p>"sitejs/.js", "sitecss/.css", "sitecss/.js" and "siteextra/.html" are applied to all non-http urls (file urls etc.).</p>
|
|
|
|
</div>
|
|
<p>Last Modified: 23 March 2026<br>
|
|
revert back doc on js with CSP sites<br>
|
|
<pre></pre>
|
|
</p>
|
|
|
|
<script id='jsgiscus'
|
|
src='https://giscus.app/client.js'
|
|
data-repo="torappinfo/uweb"
|
|
data-repo-id="MDEwOlJlcG9zaXRvcnkzMDIyMDU3MjE="
|
|
data-category="Announcements"
|
|
data-category-id="DIC_kwDOEgNLGc4CQjsh"
|
|
data-mapping="title"
|
|
data-strict="0"
|
|
data-reactions-enabled="1"
|
|
data-emit-metadata="0"
|
|
data-input-position="top"
|
|
data-theme="light"
|
|
data-lang="en"
|
|
data-loading="lazy"
|
|
crossorigin="anonymous" async>
|
|
</script>
|
|
|
|
<footer class="site-footer">
|
|
<div class="container">
|
|
© 2018-2026 Richard H. Cao
|
|
</div>
|
|
</footer>
|
|
<!-- 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/>. -->
|
|
|
|
|
|
</body>
|
|
</html>
|