-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathuserscript.js
42 lines (36 loc) · 1.49 KB
/
userscript.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
// ==UserScript==
// @include /^https://[^/]*/ep/[^/]*$/
// @include /^https://[^/]*/subject/[^/]*/edit$/
// @include /^https://[^/]*/subject/[^/]*$/
// @include /^https://[^/]*/$/
// ==/UserScript==
(() => {
const path = document.location.pathname
if (path === '/') {
$('h1').append(` <a href="https://patch.bgm38.tv/" target='_blank'><img src="https://patch.bgm38.tv/badge.svg"/></a>`)
return;
}
const episodeMatch = /^\/ep\/(\d+)/.exec(path);
if (episodeMatch) {
const episodeID = episodeMatch[1];
$('#columnEpA > h2.title').append(
`<small><a href="https://patch.bgm38.tv/suggest-episode?episode_id=${episodeID}" class="l" target="_blank">[提供修改建议]</a></small>`,
`<a href="https://patch.bgm38.tv/?type=episode" target='_blank'><img src="https://patch.bgm38.tv/badge/subject/${episodeID}"/></a>`
);
return
}
const subjectMatch = /^\/subject\/(\d+)/.exec(path);
if (subjectMatch) {
const subjectID = subjectMatch[1];
if (/^\/subject\/\d+\/edit$/.test(path)) {
$('#columnInSubjectA > a:contains("[修改]")').after(
`<a href="https://patch.bgm38.tv/suggest?subject_id=${subjectID}" class="l rr" target="_blank">[提供修改建议]</a>`
);
} else if (/^\/subject\/\d+$/.test(path)) {
$('h1.nameSingle').append(
`<a href="https://patch.bgm38.tv/?type=subject" target='_blank'><img src="https://patch.bgm38.tv/badge/subject/${subjectID}"/></a>`
)
}
return
}
})();