forked from wantora/weautopagerize
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnaver-matome.js
61 lines (56 loc) · 1.59 KB
/
naver-matome.js
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
function domFilter(url, doc) {
const currentElement = doc.querySelector(
".MdPagination03 strong, .MdPagination04 strong"
);
if (!currentElement) {
return;
}
const nextElement = currentElement.nextElementSibling;
if (!nextElement) {
return;
}
const nextURL = new URL(url);
nextURL.searchParams.set("page", nextElement.textContent);
nextElement.setAttribute("data-next-url", nextURL);
}
domFilter(location.href, document);
document.addEventListener("AutoPagerizeResponseFilterRequest", (ev) => {
const doc = new DOMParser().parseFromString(
ev.detail.responseText,
"text/html"
);
domFilter(ev.detail.responseURL, doc);
document.dispatchEvent(
new CustomEvent("AutoPagerizeResponseFilterResponse", {
detail: {
responseText: doc.documentElement.outerHTML,
},
})
);
});
document.dispatchEvent(
new CustomEvent("AutoPagerize_launchAutoPager", {
detail: {
siteinfo: [
{
url: "^https?://matome\\.naver\\.jp/odai/",
nextLink: "//*/@data-next-url",
pageElement: '//div[contains(@class, "MdMTMWidgetList01")]',
options: {
useResponseFilter: true,
},
exampleUrl: "https://matome.naver.jp/odai/2143478691035538101",
},
{
url: "^https?://matome\\.naver\\.jp/topic/",
nextLink: "//*/@data-next-url",
pageElement: '//ul[contains(@class, "MdMTMTtlList02")]',
options: {
useResponseFilter: true,
},
exampleUrl: "https://matome.naver.jp/topic/1LwZ0",
},
],
},
})
);