Repository navigation
Expand file tree
/
Copy pathuserscript.js
More file actions
65 lines (54 loc) · 2.17 KB
/
Copy pathuserscript.js
File metadata and controls
65 lines (54 loc) · 2.17 KB
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
// ==UserScript==
// @include /^https://[^/]*/ep/[^/]*$/
// @include /^https://[^/]*/subject/[^/]*/edit$/
// @include /^https://[^/]*/subject/[^/]*$/
// @include /^https://[^/]*/character/[^/]*$/
// @include /^https://[^/]*/person/[^/]*$/
// @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/edit/episode/${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/edit/subject/${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
}
const characterMatch = /^\/character\/(\d+)/.exec(path);
if (characterMatch) {
const characterID = characterMatch[1];
$('#subjectPanelIndex').before(
`<p><a href="https://patch.bgm38.tv/edit/character/${characterID}" class="l" target="_blank">[提供修改建议]</a></p>`
);
return
}
const personMatch = /^\/person\/(\d+)/.exec(path);
if (personMatch) {
const personID = personMatch[1];
$('#subjectPanelIndex').before(
`<p><a href="https://patch.bgm38.tv/edit/person/${personID}" class="l" target="_blank">[提供修改建议]</a></p>`
);
return
}
})();