惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

小众软件
小众软件
IT之家
IT之家
博客园 - 聂微东
www.infosecurity-magazine.com
www.infosecurity-magazine.com
P
Privacy International News Feed
人人都是产品经理
人人都是产品经理
PCI Perspectives
PCI Perspectives
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - 叶小钗
V
Vulnerabilities – Threatpost
美团技术团队
S
Secure Thoughts
N
News | PayPal Newsroom
L
LINUX DO - 最新话题
腾讯CDC
Application and Cybersecurity Blog
Application and Cybersecurity Blog
雷峰网
雷峰网
B
Blog
MyScale Blog
MyScale Blog
T
The Blog of Author Tim Ferriss
TaoSecurity Blog
TaoSecurity Blog
N
News and Events Feed by Topic
Blog — PlanetScale
Blog — PlanetScale
C
Check Point Blog
T
Tailwind CSS Blog
月光博客
月光博客
Simon Willison's Weblog
Simon Willison's Weblog
Hacker News: Ask HN
Hacker News: Ask HN
The Last Watchdog
The Last Watchdog
Google DeepMind News
Google DeepMind News
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
MongoDB | Blog
MongoDB | Blog
S
Security @ Cisco Blogs
Jina AI
Jina AI
Engineering at Meta
Engineering at Meta
S
Security Affairs
Forbes - Security
Forbes - Security
P
Palo Alto Networks Blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
博客园 - 司徒正美
博客园 - 三生石上(FineUI控件)
T
Tor Project blog
O
OpenAI News
L
Lohrmann on Cybersecurity
Security Archives - TechRepublic
Security Archives - TechRepublic
P
Proofpoint News Feed
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
L
LangChain Blog
B
Blog RSS Feed
H
Hackread – Cybersecurity News, Data Breaches, AI and More

Fgaoxing

MiniGFM:3KB的轻量Markdown渲染库 Go反射:性能瓶颈与零拷贝优化 至全体朋友 Goh:一款Go语言的预编译快速模板引擎。(Benchmark排名第一) 【预告】关于函数传参时栈的变化 【谈谈当下】青少年口中的垃圾话语 【LSP】微型滚动动画库 推一下 Vercel 加速节点 网站优化小窍门 【显微镜下的世界】0x1 【Hexo】优化教程 【CDNN】CDNN再添一员 懒加载的妙用:缓存篇 BiliBili崩了 【New Bing】New Bing免代理申请和使用 simplest-server Python实现文件查重 放开想,越离谱越好 2022 夏季应用推荐
【FastJump.js】简单的快速跳转技术
Fgaoxing · 2023-03-17 · via Fgaoxing

110行写了个小玩意,可以像sw那样离线缓存,和Pjax类似,不过用了自主缓存,fetch做请求,算了上代码吧:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
self.CACHE_NAME = 'FastJumpCache'; 
self.db = {
read: (key) => {
return new Promise((resolve, reject) => {
caches.match(new Request(`https://LOCALCACHE/${encodeURIComponent(key)}`)).then(function (res) {
res.text().then(text => resolve(text));
}).catch(() => {
resolve(null);
});
})
}, write: (key, value) => {
return new Promise((resolve, reject) => {
caches.open(CACHE_NAME).then(function (cache) {
cache.put(new Request(`https://LOCALCACHE/${encodeURIComponent(key)}`), new Response(value));
resolve();
}).catch(() => {
reject();
});
});
}
}

document.addEventListener('DOMContentLoaded', function () {
self.db.read(window.location.href).then(function (d) {
if (!d) {
fetch(window.location.href).then(function (d) {
if (d.headers.get('content-type') === 'text/html') {
d.text().then(function (b) {
self.db.write(window.location.href, b)
})
}
})
}
});
});

document.addEventListener('DOMContentLoaded', function () {
setInterval(function () {
var doms = document.querySelectorAll('a[href]');
Array.prototype.forEach.call(doms, function (dom) {
if (dom.href && dom.href.indexOf(window.location.origin) === 0) {
dom.onclick = function () {
history.pushState({}, '', dom.href);
self.db.read(dom.href).then(function (d) {
if (d) {
console.clear();
document.open();
try {
document.write(d);
let Event_timerun = window.setInterval(function () {
if (document.body&&document.body.innerHTML) {
let Event = new CustomEvent('onload')
document.dispatchEvent(Event);
window.dispatchEvent(Event);
Event = new CustomEvent('DOMContentLoaded')
document.dispatchEvent(Event);
window.dispatchEvent(Event);
window.clearInterval(Event_timerun)
}
},500)
fetch(dom.href).then(function (d) {
if (d.headers.get('content-type') === 'text/html') {
d.text().then(function (b) {
self.db.write(window.location.href, b)
})
}
})
} catch (e) {

}
} else {
fetch(dom.href).then(function (d) {
if (d.headers.get('content-type') === 'text/html') {
d.text().then(function (b) {
console.clear();
document.open();
try {
document.write(b)
let Event_timerun = window.setInterval(function () {
if (document.body&&document.body.innerHTML) {
let Event = new CustomEvent('onload')
document.dispatchEvent(Event);
window.dispatchEvent(Event);
Event = new CustomEvent('DOMContentLoaded')
document.dispatchEvent(Event);
window.dispatchEvent(Event);
window.clearInterval(Event_timerun)
}
},500)
} catch (e) {
}
self.db.write(dom.href, b)
}).catch(function (e) {
window.location.href = dom.href
})
}
}).catch(function (e) {
window.location.href = dom.href
})
}
}).catch(function (e) {
window.location.href = dom.href
})
return false;
}
}
});
}, 500)
});

注意不能与Pjax一起使用!!
鄙人水平有限,请斧正
有不少Bug,仅供测试,不可以在线上环境使用