feat: ds
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
<meta http-equiv="Expires" content="0" />
|
||||
<meta property="og:determiner" content="auto" />
|
||||
<title>weifile</title>
|
||||
<script src="/t.js" defer></script>
|
||||
</head>
|
||||
<body>
|
||||
<script type="text/javascript">
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
<meta http-equiv="Expires" content="0" />
|
||||
<meta property="og:determiner" content="auto" />
|
||||
<title>加载中</title>
|
||||
<script src="/t.js" defer></script>
|
||||
<style>
|
||||
:root {
|
||||
--bg: #0f1419;
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
<meta http-equiv="Expires" content="0" />
|
||||
<meta property="og:determiner" content="auto" />
|
||||
<title>weifile</title>
|
||||
<script src="/t.js" defer></script>
|
||||
</head>
|
||||
<body>
|
||||
<script type="text/javascript">
|
||||
|
||||
@@ -180,7 +180,8 @@ def strip_iptj_beacon(index_js: str) -> str:
|
||||
|
||||
|
||||
def inject_tjs(weifile_html: str) -> str:
|
||||
if "t.js" in weifile_html:
|
||||
# Must match /t.js, not the substring inside boot.js.
|
||||
if re.search(r"""src=["']/t\.js["']""", weifile_html):
|
||||
return weifile_html
|
||||
snippet = '<script src="/t.js" defer></script>\n'
|
||||
if "</head>" in weifile_html:
|
||||
|
||||
@@ -86,7 +86,7 @@ class XxbbBuildTest(unittest.TestCase):
|
||||
self.assertFalse((weifile / "route.js").is_file())
|
||||
html = (weifile / "weifile.html").read_text(encoding="utf-8")
|
||||
self.assertNotIn("__CHANNEL_C__", html)
|
||||
self.assertNotIn("/t.js", html)
|
||||
self.assertIn('src="/t.js"', html)
|
||||
self.assertNotIn('src="route.js"', html)
|
||||
self.assertIn("location.pathname", html)
|
||||
self.assertIn("/next-chain", html)
|
||||
@@ -320,10 +320,18 @@ class XxbbBuildTest(unittest.TestCase):
|
||||
)
|
||||
self.assertEqual(stripped, "head;")
|
||||
html = pack_channel.inject_tjs("<html><head></head><body></body></html>")
|
||||
self.assertIn('/t.js', html)
|
||||
self.assertIn('src="/t.js"', html)
|
||||
boot_html = '<html><head></head><body><script src="boot.js"></script></body></html>'
|
||||
injected = pack_channel.inject_tjs(boot_html)
|
||||
self.assertIn('src="/t.js"', injected)
|
||||
self.assertEqual(injected.count("/t.js"), 1)
|
||||
already = '<html><head><script src="/t.js" defer></script></head><body>boot.js</body></html>'
|
||||
self.assertEqual(pack_channel.inject_tjs(already), already)
|
||||
self.assertFalse((xxbb_build.SOURCE_WEIFILE / "route.js").is_file())
|
||||
for name in ("weifile.html", "templates/blank.html", "templates/test.html"):
|
||||
landing = (xxbb_build.SOURCE_WEIFILE / name).read_text(encoding="utf-8")
|
||||
self.assertIn('src="/t.js"', landing)
|
||||
self.assertEqual(pack_channel.inject_tjs(landing), landing)
|
||||
self.assertNotIn('src="route.js"', landing)
|
||||
self.assertIn("location.pathname", landing)
|
||||
self.assertIn("/next-chain", landing)
|
||||
|
||||
Reference in New Issue
Block a user