q78kgblog 0.0.0-1719742982616 → 0.0.0-1719743593542

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/404.html +3 -3
  2. package/about/index.html +5 -5
  3. package/archives/2023/02/index.html +4 -4
  4. package/archives/2023/04/index.html +4 -4
  5. package/archives/2023/05/index.html +4 -4
  6. package/archives/2023/08/index.html +4 -4
  7. package/archives/2023/09/index.html +4 -4
  8. package/archives/2023/index.html +4 -4
  9. package/archives/2024/01/index.html +4 -4
  10. package/archives/2024/02/index.html +4 -4
  11. package/archives/2024/index.html +4 -4
  12. package/archives/index.html +4 -4
  13. package/atom.xml +9 -9
  14. package/bangumis/index.html +4 -4
  15. package/bigpie/index.html +3 -3
  16. package/categories/Hexo/index.html +4 -4
  17. package/categories/index.html +3 -3
  18. package/categories//345/271/264/347/273/210/346/200/273/347/273/223/index.html +4 -4
  19. package/categories//347/264/240/346/235/220/index.html +4 -4
  20. package/categories//351/227/262/350/201/212/346/235/202/350/260/210/index.html +4 -4
  21. package/content.json +1 -1
  22. package/fcircle/index.html +3 -3
  23. package/fontawesome/index.html +3 -3
  24. package/index.html +12 -12
  25. package/links/index.html +3 -3
  26. package/othersite/index.html +3 -3
  27. package/package.json +1 -1
  28. package/posts/164ef646/index.html +5 -5
  29. package/posts/228c2ef8/index.html +5 -5
  30. package/posts/a9a6c1fb/index.html +5 -5
  31. package/posts/c262e439/index.html +5 -5
  32. package/posts/c81531cf/index.html +5 -5
  33. package/posts/ccdf7cfc/index.html +5 -5
  34. package/posts/de1f83f4/index.html +5 -5
  35. package/posts/e54f7476/index.html +5 -5
  36. package/random.html +2 -2
  37. package/sitemap.txt +2 -2
  38. package/sitemap.xml +6 -6
  39. package/sw.js +70 -91
  40. package/tags/AI/index.html +5 -5
  41. package/tags/Butterfly/index.html +5 -5
  42. package/tags/Cloudflare/index.html +5 -5
  43. package/tags/DiffSinger/index.html +5 -5
  44. package/tags/Hexo/index.html +5 -5
  45. package/tags/Next/index.html +5 -5
  46. package/tags/RAID/index.html +5 -5
  47. package/tags/Vercel/index.html +5 -5
  48. package/tags/Workers/index.html +5 -5
  49. package/tags/index.html +4 -4
  50. package/tags//344/270/273/351/242/230/index.html +5 -5
  51. package/tags//345/206/231/344/275/234/index.html +5 -5
  52. package/tags//345/245/263/346/200/247/346/204/217/350/257/206/index.html +5 -5
  53. package/tags//345/255/246/344/271/240/index.html +5 -5
  54. package/tags//345/256/266/351/207/214/344/272/221/index.html +5 -5
  55. package/tags//345/271/264/347/273/210/346/200/273/347/273/223/index.html +5 -5
  56. package/tags//346/212/230/350/205/276/index.html +5 -5
  57. package/tags//346/227/245/345/270/270/index.html +5 -5
  58. package/tags//346/234/215/345/212/241/345/231/250/index.html +5 -5
  59. package/tags//346/265/252/346/275/256/index.html +5 -5
  60. package/tags//347/256/200/347/210/261/index.html +5 -5
  61. package/tags//350/207/252/345/212/250/346/240/207/346/263/250/index.html +5 -5
  62. package/tags//350/256/272/346/226/207/index.html +5 -5
  63. package/tags//350/260/267/346/255/214/347/277/273/350/257/221/index.html +5 -5
  64. package/tags//350/264/237/350/275/275/345/235/207/350/241/241/index.html +5 -5
  65. package/tags//351/207/221/345/217/245/index.html +5 -5
  66. package/tags//351/255/224/346/224/271/index.html +5 -5
package/sitemap.txt CHANGED
@@ -10,12 +10,12 @@ https://anjiurine.top/manifest.json
10
10
  https://anjiurine.top/othersite/index.html
11
11
  https://anjiurine.top/tags/index.html
12
12
  https://anjiurine.top/links/index.html
13
+ https://anjiurine.top/fcircle/index.html
14
+ https://anjiurine.top/fontawesome/index.html
13
15
  https://anjiurine.top/about/index.html
14
16
  https://anjiurine.top/bangumis/index.html
15
17
  https://anjiurine.top/bigpie/index.html
16
18
  https://anjiurine.top/categories/index.html
17
- https://anjiurine.top/fcircle/index.html
18
- https://anjiurine.top/fontawesome/index.html
19
19
  https://anjiurine.top/
20
20
  https://anjiurine.top/tags/%E6%97%A5%E5%B8%B8/
21
21
  https://anjiurine.top/tags/%E5%B9%B4%E7%BB%88%E6%80%BB%E7%BB%93/
package/sitemap.xml CHANGED
@@ -110,7 +110,7 @@
110
110
  </url>
111
111
 
112
112
  <url>
113
- <loc>https://anjiurine.top/about/index.html</loc>
113
+ <loc>https://anjiurine.top/fcircle/index.html</loc>
114
114
 
115
115
  <lastmod>2024-06-30</lastmod>
116
116
 
@@ -119,7 +119,7 @@
119
119
  </url>
120
120
 
121
121
  <url>
122
- <loc>https://anjiurine.top/bangumis/index.html</loc>
122
+ <loc>https://anjiurine.top/fontawesome/index.html</loc>
123
123
 
124
124
  <lastmod>2024-06-30</lastmod>
125
125
 
@@ -128,7 +128,7 @@
128
128
  </url>
129
129
 
130
130
  <url>
131
- <loc>https://anjiurine.top/bigpie/index.html</loc>
131
+ <loc>https://anjiurine.top/about/index.html</loc>
132
132
 
133
133
  <lastmod>2024-06-30</lastmod>
134
134
 
@@ -137,7 +137,7 @@
137
137
  </url>
138
138
 
139
139
  <url>
140
- <loc>https://anjiurine.top/categories/index.html</loc>
140
+ <loc>https://anjiurine.top/bangumis/index.html</loc>
141
141
 
142
142
  <lastmod>2024-06-30</lastmod>
143
143
 
@@ -146,7 +146,7 @@
146
146
  </url>
147
147
 
148
148
  <url>
149
- <loc>https://anjiurine.top/fcircle/index.html</loc>
149
+ <loc>https://anjiurine.top/bigpie/index.html</loc>
150
150
 
151
151
  <lastmod>2024-06-30</lastmod>
152
152
 
@@ -155,7 +155,7 @@
155
155
  </url>
156
156
 
157
157
  <url>
158
- <loc>https://anjiurine.top/fontawesome/index.html</loc>
158
+ <loc>https://anjiurine.top/categories/index.html</loc>
159
159
 
160
160
  <lastmod>2024-06-30</lastmod>
161
161
 
package/sw.js CHANGED
@@ -12,19 +12,23 @@ self.addEventListener('install', async function (installEvent) {
12
12
  });
13
13
  self.addEventListener('fetch', async event => {
14
14
  try {
15
- event.respondWith(handle(event.request))
15
+ event.respondWith(handle(event.request));
16
16
  } catch (msg) {
17
- event.respondWith(handleerr(event.request, msg))
17
+ event.respondWith(handleerr(event.request, msg));
18
18
  }
19
19
  });
20
20
  const handleerr = async (req, msg) => {
21
21
  return new Response(`<h1>CDN分流器遇到了致命错误</h1>
22
- <b>${msg}</b>`, { headers: { "content-type": "text/html; charset=utf-8" } })
22
+ <b>${msg}</b>`, { headers: { "content-type": "text/html; charset=utf-8" } });
23
23
  }
24
- const lfetch = async (urls, url) => {
24
+ const lfetch = async (urls) => {
25
25
  let controller = new AbortController();
26
26
  const PauseProgress = async (res) => {
27
- return new Response(await (res).arrayBuffer(), { status: res.status, headers: res.headers });
27
+ let status = res.status;
28
+ if (status < 200 || status > 599) {
29
+ status = 200;
30
+ }
31
+ return new Response(await res.arrayBuffer(), { status: status, headers: res.headers });
28
32
  };
29
33
  if (!Promise.any) {
30
34
  Promise.any = function (promises) {
@@ -47,81 +51,68 @@ const lfetch = async (urls, url) => {
47
51
  })
48
52
  }
49
53
  }
50
- return Promise.any(urls.map(urls => {
54
+ return Promise.any(urls.map(url => {
51
55
  return new Promise((resolve, reject) => {
52
- fetch(urls, {
56
+ fetch(url, {
53
57
  signal: controller.signal,
54
- mode: 'no-cors'
58
+ mode: 'no-cors' // 添加 no-cors 模式
55
59
  })
56
60
  .then(PauseProgress)
57
61
  .then(res => {
58
62
  if (res.status == 200) {
59
63
  controller.abort();
60
- resolve(res)
64
+ resolve(res);
61
65
  } else {
62
- reject(res)
66
+ reject(res);
63
67
  }
64
68
  })
65
69
  })
66
70
  }))
67
71
  }
68
72
  self.addEventListener('fetch', async event => {
69
- try{
70
- event.respondWith(handle(event.request))
71
- }catch(err){
72
- if(fullpath(urlPath).indexOf(".html")!=-1){
73
- event.respondWith(fetch("/404.html"))
73
+ try {
74
+ event.respondWith(handle(event.request));
75
+ } catch (err) {
76
+ if (fullpath(event.request.url).indexOf(".html") != -1) {
77
+ event.respondWith(fetch("/404.html"));
74
78
  }
75
79
  }
76
80
  });
77
81
  const fullpath = (path) => {
78
- path = path.split('?')[0].split('#')[0]
82
+ path = path.split('?')[0].split('#')[0];
79
83
  if (path.match(/\/$/)) {
80
- path += 'index'
84
+ path += 'index';
81
85
  }
82
86
  if (!path.match(/\.[a-zA-Z]+$/)) {
83
- path += '.html'
87
+ path += '.html';
84
88
  }
85
- return path
89
+ return path;
86
90
  }
87
91
  const generate_blog_urls = (packagename, blogversion, path) => {
88
92
  const npmmirror = [
89
- // `https://unpkg.zhimg.com/${packagename}@${blogversion}`,
90
- // `https://npm.elemecdn.com/${packagename}@${blogversion}`,
91
- // `https://cdn1.tianli0.top/npm/${packagename}@${blogversion}`,
92
- // `https://cdn.afdelivr.top/npm/${packagename}@${blogversion}`,
93
- // `https://ariasakablog.s3.ladydaily.com`,
94
- // `https://registry.npmmirror.com/${packagename}/${blogversion}/files`,
95
- // `https://cdn.cbd.int/${packagename}@${blogversion}`
96
- 'https://raw.gitcode.com/Q78KG/Hexoshelf/raw/gh-pages-blog'
97
- ]
98
- for (var i in npmmirror) {
99
- npmmirror[i] += path
100
- }
101
- return npmmirror
93
+ // Add the URLs as needed
94
+ ];
95
+ return npmmirror.map(url => `${url}${path}`);
102
96
  }
97
+
103
98
  const mirror = [
104
- // `https://registry.npmmirror.com/ariasakablog/latest`,
105
- // `https://registry.npmjs.org/ariasakablog/latest`,
106
- // `https://registry.npmmirror.com/q78kgblog/latest`,
107
- // `https://cdn.cbd.int/q78kgblog`,
108
- // `https://mirrors.cloud.tencent.com/npm/q78kgblog/latest`
99
+ // Add the mirror URLs as needed
109
100
  ]
110
101
  const get_newest_version = async (mirror) => {
111
- return lfetch(mirror, mirror[0])
112
- .then(res => res.json())
113
- .then(res.version)
102
+ return lfetch(mirror)
103
+ .then(res => res.json())
104
+ .then(res => res.version);
114
105
  }
115
- self.db = { //全局定义db,只要read和write,看不懂可以略过
106
+ self.db = {
116
107
  read: (key, config) => {
117
108
  if (!config) { config = { type: "text" } }
118
109
  return new Promise((resolve, reject) => {
119
110
  caches.open(CACHE_NAME).then(cache => {
120
111
  cache.match(new Request(`https://LOCALCACHE/${encodeURIComponent(key)}`)).then(function (res) {
121
- if (!res) resolve(null)
122
- res.text().then(text => resolve(text))
112
+ if (!res) resolve(null);
113
+ res.text().then(text => resolve(text));
123
114
  }).catch(() => {
124
- resolve(null)
115
+ resolve(null);
125
116
  })
126
117
  })
127
118
  })
@@ -130,66 +121,54 @@ self.db = { //全局定义db,只要read和write,看不懂可以略过
130
121
  return new Promise((resolve, reject) => {
131
122
  caches.open(CACHE_NAME).then(function (cache) {
132
123
  cache.put(new Request(`https://LOCALCACHE/${encodeURIComponent(key)}`), new Response(value));
133
- resolve()
124
+ resolve();
134
125
  }).catch(() => {
135
- reject()
126
+ reject();
136
127
  })
137
128
  })
138
129
  }
139
130
  }
140
131
 
141
- const set_newest_version = async (mirror) => { //改为最新版本写入数据库
142
- return lfetch(mirror, mirror[0])
143
- .then(res => res.json()) //JSON Parse
132
+ const set_newest_version = async (mirror) => {
133
+ return lfetch(mirror)
134
+ .then(res => res.json())
144
135
  .then(async res => {
145
- await db.write('blog_version', res.version) //写入
146
- return;
147
- })
136
+ await db.write('blog_version', res.version);
137
+ });
148
138
  }
149
139
 
150
- setInterval(async() => {
151
- await set_newest_version(mirror) //定时更新,一分钟一次
152
- }, 60*1000);
140
+ setInterval(async () => {
141
+ await set_newest_version(mirror);
142
+ }, 60 * 1000);
143
+
144
+ setTimeout(async () => {
145
+ await set_newest_version(mirror);
146
+ }, 5000);
153
147
 
154
- setTimeout(async() => {
155
- await set_newest_version(mirror)//打开五秒后更新,避免堵塞
156
- },5000)
157
148
  function getFileType(fileName) {
158
- suffix=fileName.split('.')[fileName.split('.').length-1]
159
- if(suffix=="html"||suffix=="htm") {
160
- return 'text/html';
161
- }
162
- if(suffix=="js") {
163
- return 'text/javascript';
164
- }
165
- if(suffix=="css") {
166
- return 'text/css';
167
- }
168
- if(suffix=="jpg"||suffix=="jpeg") {
169
- return 'image/jpeg';
170
- }
171
- if(suffix=="ico") {
172
- return 'image/x-icon';
173
- }
174
- if(suffix=="png") {
175
- return 'image/png';
176
- }
177
- return 'text/plain';
178
- }
179
- const handle = async(req)=>{
180
- const urlStr = req.url
149
+ const suffix = fileName.split('.').pop();
150
+ const types = {
151
+ "html": 'text/html',
152
+ "htm": 'text/html',
153
+ "js": 'text/javascript',
154
+ "css": 'text/css',
155
+ "jpg": 'image/jpeg',
156
+ "jpeg": 'image/jpeg',
157
+ "ico": 'image/x-icon',
158
+ "png": 'image/png'
159
+ };
160
+ return types[suffix] || 'text/plain';
161
+ }
162
+ const handle = async (req) => {
163
+ const urlStr = req.url;
181
164
  const urlObj = new URL(urlStr);
182
165
  const urlPath = urlObj.pathname;
183
166
  const domain = urlObj.hostname;
184
- //从这里开始
185
- lxs=[]
186
- if(domain === "anjiurine.top"){//这里写你需要拦截的域名
187
- var l=lfetch(generate_blog_urls('q78kgblog',await db.read('blog_version') || 'latest',fullpath(urlPath)))
188
- return l
189
- .then(res=>res.arrayBuffer())
190
- .then(buffer=>new Response(buffer,{headers:{"Content-Type":`${getFileType(fullpath(urlPath).split("/")[fullpath(urlPath).split("/").length-1].split("\\")[fullpath(urlPath).split("/")[fullpath(urlPath).split("/").length-1].split("\\").length-1])};charset=utf-8`}}));//重新定义header
191
- }
192
- else{
193
- return fetch(req);
167
+ if (domain === "anjiurine.top") {
168
+ return lfetch(generate_blog_urls('q78kgblog', await db.read('blog_version') || 'latest', fullpath(urlPath)))
169
+ .then(res => res.arrayBuffer())
170
+ .then(buffer => new Response(buffer, { headers: { "Content-Type": `${getFileType(fullpath(urlPath))}; charset=utf-8` } }));
171
+ } else {
172
+ return fetch(req, { mode: 'no-cors' });
194
173
  }
195
174
  }