更新 Chrome 扩展
js
JSON.stringify(
[
...document
.querySelector("extensions-manager")
.shadowRoot.querySelector("#items-list")
.shadowRoot.querySelectorAll("extensions-item"),
].map((e) => ({
id: e.shadowRoot
.querySelector("#extension-id")
.innerText.replace(/^ID.*?(\w)/, "$1"),
name: e.shadowRoot.querySelector("#name").innerText,
version: e.shadowRoot.querySelector("#version").innerText,
}))
);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
2
3
4
5
6
7
8
9
10
11
12
13
14
js
location.href = "https://www.crxsoso.com";
1
js
(async () => {
const input = prompt("请输入扩展数据");
if (typeof input === "string") {
const data = JSON.parse(input);
const updateList = [];
for (let item of data) {
try {
const rawHtml = await fetch(
`https://www.crxsoso.com/webstore/detail/${item.id}`
).then((e) => e.text());
const $ = new DOMParser().parseFromString(rawHtml, "text/html");
const newVersion = [
...[...$.querySelectorAll("#right-info > div")].filter(
(e) => e.innerText === "版本"
)[0].nextElementSibling.childNodes,
]
.filter((e) => e instanceof Text)
.map((e) => e.textContent)
.join("")
.trim();
if (item.version != newVersion) {
updateList.push({
名称: item.name,
当前版本: item.version,
最新版本: newVersion,
网址: `https://www.crxsoso.com/webstore/detail/${item.id}`,
});
}
} catch {
updateList.push({
名称: item.name,
当前版本: item.version,
最新版本: "无法获取最新版本",
网址: `https://www.crxsoso.com/webstore/detail/${item.id}`,
});
}
}
if (updateList.length) {
console.log("发现以下更新");
console.table(updateList);
for (let item of updateList) {
console.log(item.名称, item.网址);
}
} else {
console.log("扩展都是最新版本了");
}
}
})();
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
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