Skip to content

Commit 8b657b7

Browse files
committed
feat: ✨ 新 sw.js & 更新文章
1 parent 931c8e2 commit 8b657b7

16 files changed

Lines changed: 142 additions & 474 deletions

File tree

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
- 使用 [Waline][3] 作为评论系统
1818
- 使用 [TGTalk][4] 作为说说系统
1919
- 使用 [Umami][5] 作为数据统计系统
20-
- 博客使用 Service Worker 和 [NPMMirror][6] 进行访问加速
20+
- 博客使用 [Service Worker][8][NPMMirror][6] 进行访问加速
2121
- 博客使用通义千问 & ChatGPT-4 Turbo 进行部分代码编写
2222
- 博客协议采用 [CC BY-NC-SA 4.0][7]
2323

@@ -34,3 +34,4 @@
3434
[5]: https://umami.is/
3535
[6]: https://npmmirror.com/
3636
[7]: https://blog.hesiy.cn/policy/
37+
[8]: https://github.com/FloatSheep/service-worker

content/about/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ xml: false
1313

1414
<style>.emoji-object { display: inline-block; padding-left: 2px; padding-bottom: 2px; height: 37px; }</style>
1515

16-
<div >:waving_hand_color: 我是 FloatSheep(巨蟹座,he/him),是一个 <span class="typer" style="--i: 0;" data-text="Student.">Student.</span> <span class="typer" style="--i: 1;" data-text="Coder(garbage).">Coder(garbage).</span> <span class="typer" style="--i: 2;" data-text="Dreamer.">Dreamer.</span></div>
16+
<div >👋 我是 FloatSheep(巨蟹座,he/him),是一个 <span class="typer" style="--i: 0;" data-text="Student.">Student.</span> <span class="typer" style="--i: 1;" data-text="Coder(garbage).">Coder(garbage).</span> <span class="typer" style="--i: 2;" data-text="Dreamer.">Dreamer.</span></div>
1717

1818
> 浮杨,一个拥有敏感心灵和深刻感性的灵魂,面对学习和生活中的挑战,他有着一份坚韧不拔的决心。在校园这个多彩的小宇宙中,他既是观察者,也是参与者,经历着成长的甘苦与考验。尽管偶尔会在压力的重重包围下流露出脆弱,但他总能从中汲取力量,如同凤凰涅槃,焕发新的生命力。浮杨正逐步踏出内向的阴影,朝向外向的阳光大步前行,带着对未来满满的期待和改变的勇气。他深知,未来的路由自己铺就,每一个努力的今天,都是为了更加灿烂的明天。
1919
@@ -28,4 +28,4 @@ xml: false
2828

2929
座右铭:『适水而行,不失心航』
3030

31-
:globe_with_meridians_color: 坐标: **Hubei, China**
31+
🌏 坐标: **Hubei, China**
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
---
2+
title: "笔记 | 用自动化克服我的懒惰"
3+
slug: "a-practical-use-of-automation"
4+
date: 2025-06-26T18:14:23+08:00
5+
cover:
6+
thumbnail:
7+
draft: false
8+
categories: "automatic"
9+
tags: ["automatic"]
10+
gemini: true
11+
showSummary: true
12+
summary: 为了和不想起床的懒惰抗衡,使用自动化程序成为了我的选择
13+
---
14+
15+
## 起因
16+
17+
其实在中考前我就规划了暑假,但是一放假,我就会因为懒癌晚期而不想起床,这就打乱了我的计划
18+
19+
## 采用方法
20+
21+
由于我的问题是不能够起床,因此我选择了醒来后锁机的方式
22+
23+
{{< alert "sun" >}}
24+
将醒来作为条件,是因为我的穿戴设备(Xiaomi Watch S1)可以提供准确的苏醒时间,而我每次醒来后第一时间就会拿手机
25+
{{< /alert >}}
26+
27+
当然,还有一种方法是将手机放在房间外面,但是这对于我来说做不到😭😭
28+
29+
根据我的需求,很容易选择以下组合
30+
31+
- `MacroDroid` 实现自动化,清醒状态进行锁机操作
32+
- `自律锁机` 作为锁机工具,就不需要重复造轮子了
33+
34+
考虑到 `自律锁机` 没有提供外部调用锁机的方法(当然也可能是我没发现),所以我决定用 Shell 脚本实现
35+
36+
## 实现
37+
38+
### 获取所需的 Activity
39+
40+
因为我这里的 `MacroDroid` 直接使用内置方法打开应用程序会出问题,所以我选择用 Shell 调用 Activity
41+
42+
`MT 管理器` 提供了 **Activity 记录** 功能
43+
44+
启动服务,然后进入锁机工具,再返回 `MT 管理器`,这里就会将我需要的 Activity 显示出来
45+
46+
### 获取控件位置
47+
48+
有了 Activity 还不够,我还需要获取锁机按钮的位置
49+
50+
因为锁机工具的锁机要分两步(锁机 -> 确定),所以我要获取两个控件位置
51+
52+
通过 `uiautomator` 就可以轻松完成
53+
54+
进入 `Termux` 并切换到 root 用户,将其挂在小窗
55+
56+
进入锁机工具后在 `Termux` 中输入 `uiautomator dump /sdcard/ui.xml`,将屏幕 UI 结构导出为 xml 文件
57+
58+
进入文件,搜索关键词 **锁机**,找到 `bounds`,这一项记录了控件的对角线坐标,其格式为 <code>[x<sub>1</sub>,y<sub>1</sub>] [x<sub>2</sub>,y<sub>2</sub>]</code>,使用简单的数学运算就可以得到控件的点击位置
59+
60+
{{< katex >}}
61+
$$
62+
x = \frac{(x_1+x_2)}{2}
63+
$$
64+
$$
65+
y = \frac{(y_1+y_2)}{2}
66+
$$
67+
68+
计算后坐标 (\\(x,y\\)) 即为需要的点击坐标
69+
70+
同理,确定控件的点击位置获取方法如上
71+
72+
{{< alert "circle-info" >}}
73+
非 root 情况下,可以使用 `adb` 执行对应命令
74+
75+
除此之外,`getevent -l` 也可以用来获取点击坐标
76+
77+
{{< /alert >}}
78+
79+
### 编辑 MacroDroid(动作)
80+
81+
触发器略
82+
83+
首先需要启动应用,在 `MacroDroid` 中添加动作 `Shell 脚本`,选择 **已 Root**(非 root 选择 **Shizuku**),在其中输入 `am start -n com.lwtsj.locks/.Mainpoi` 并勾选 **完成后才能继续动作**
84+
85+
再次,添加动作 `等待 1 秒`,避免应用未加载完全时进行操作
86+
87+
然后点击 **锁机**,添加动作 `Shell 脚本`,配置相同,输入 `input tap x y`
88+
89+
接着点击 **确定**,添加动作 `Shell 脚本`,配置相同,输入 `input tap x y`
90+
91+
完成后点击右上角三点,选择测试动作,成功锁机即为成功

content/posts/android-windows-subsystem/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ Fork 完后进入 Actions
119119

120120
![image-20220625192815258](https://api.hesiy.cn/api/cross?fetch=https://i0.hdslb.com/bfs/album/0703670b18b07223bbe9425f00613183aaf51e4d.png)
121121

122-
## 安装 LSPosed
122+
## 安装 LSPosed
123123

124124
[LSPosed Repo](https://github.com/LSPosed/LSPosed/)
125125

Lines changed: 1 addition & 1 deletion
Loading

content/posts/open-port-in-nat/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: "NAT 网络环境下获得被外网访问的权利"
2+
title: "NAT 简介 & 端口开放"
33
slug: "open-port-in-nat"
44
date: 2024-07-28T12:28:22+08:00
55
cover: cover.svg
@@ -9,7 +9,7 @@ categories: "nat"
99
tags: ["learn"]
1010
gemini: true
1111
showSummary: true
12-
summary: 我要,重新找回被访问权利!
12+
summary: NAT 的介绍及 NAT 下端口映射
1313
---
1414

1515
{{< alert >}}

content/posts/pictures-bed/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ SESSDATA 可以登录哔哩哔哩后查看
8383
阿里 CDN 路线:
8484

8585
- i1.hdslb.com
86-
- 14.hdslb.com
86+
- i4.hdslb.com
8787
- s1.hdslb.com
8888
- s3.hdslb.com
8989

layouts/partials/analytics.html

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
document.addEventListener("DOMContentLoaded", (event) => {
88
if ("serviceWorker" in navigator) {
99
navigator.serviceWorker
10-
.register("/sw.js")
10+
.register("/sw.js?t=" + new Date().getTime(), { type: "module" })
1111
.then(function (registration) {
1212
console.log("Service Worker 注册成功:", registration);
1313
})
@@ -23,11 +23,9 @@
2323
window.fm || (window.fm = {});
2424

2525
window.fm.refresh = () => {
26-
if (navigator.serviceWorker.controller) {
27-
navigator.serviceWorker.controller.postMessage({
28-
action: "force-refresh",
29-
});
30-
}
26+
navigator.serviceWorker.getRegistrations().then((registrations) => {
27+
registrations.forEach((sw) => sw.unregister());
28+
});
3129
};
3230

3331
/* function debounce(func, delay) {

layouts/partials/cfai.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,4 +185,5 @@
185185
location.href = `/posts/qwen-summary`;
186186
});
187187
});
188+
document.currentScript.remove();
188189
</script>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<script>
2+
function getCookie(name) {
3+
const decodedCookie = decodeURIComponent(document.cookie);
4+
const cookies = decodedCookie.split(';');
5+
const fullCookieName = name + "=";
6+
for(let i = 0; i < cookies.length; i++) {
7+
const cookie = cookies[i].trim();
8+
if (cookie.indexOf(fullCookieName) === 0) {
9+
return cookie.substring(fullCookieName.length, cookie.length);
10+
}
11+
}
12+
return undefined;
13+
}
14+
document.addEventListener('DOMContentLoaded', (event) => {
15+
if (document.mB && typeof document.mB.show === 'function') {
16+
if(getCookie('mbShow') !== 'true') {
17+
document.mB.show("Service Worker 进行了重写!网页出现错误时,可以试试页面底部的两点按键!", true, "我已知晓", "#FFF", "top-right", 5000);
18+
document.cookie = "mbShow=true; path=/";
19+
}
20+
} else {
21+
console.error('mB is not defined or show is not a function!');
22+
}
23+
pagemap(document.querySelector('#pagemap'), {
24+
viewport: null,
25+
styles: {
26+
'header,footer,section,article': 'rgba(0,0,0,0.08)',
27+
'h1,a': 'rgba(0,0,0,0.10)',
28+
'h2,h3,h4': 'rgba(0,0,0,0.08)'
29+
},
30+
back: 'rgba(0,0,0,0.02)',
31+
view: 'rgba(0,0,0,0.05)',
32+
drag: 'rgba(0,0,0,0.10)',
33+
interval: null
34+
});
35+
});
36+
</script>

0 commit comments

Comments
 (0)