Skip to content

Commit 921c267

Browse files
committed
ステータス変更
1 parent bff11e4 commit 921c267

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

src/create-record-button.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,13 @@ export async function createRecordButton() {
4242
function singleRecordButton(i: number, j: number) {
4343
const button = document.querySelectorAll(".record-button:first-of-type")[j];
4444
button.addEventListener("click", async () => {
45+
const recordContainer = document.querySelectorAll(".record-container");
4546
let mutation = "mutation{";
4647

4748
// 視聴ステータスが"見てる"以外だった場合、"見てる"に変更
48-
mutation = changeStatusToWatching(mutation);
49+
if (!(!isAiring && j === recordContainer.length - 1)) {
50+
mutation = changeStatusToWatching(mutation);
51+
}
4952

5053
mutation += `
5154
createRecord (
@@ -56,7 +59,7 @@ export async function createRecordButton() {
5659
// 最終話まで見ている場合は、ステータスを"見た"に変更
5760
if (
5861
!isAiring && // アニメが放送終了
59-
j === document.querySelectorAll(".record-container").length - 1 // 最終話
62+
j === recordContainer.length - 1 // 最終話
6063
) {
6164
mutation += `
6265
updateStatus(
@@ -81,11 +84,14 @@ export async function createRecordButton() {
8184
function multiRecordButton(i: number, j: number) {
8285
const button = document.querySelectorAll(".record-button:last-of-type")[j];
8386
button.addEventListener("click", async () => {
87+
const recordContainer = document.querySelectorAll(".record-container");
8488
// その話数までのcreateRecordを作成してマージ
8589
let mutation = "mutation{";
8690

8791
// ステータスを"見たい"に変更
88-
mutation = changeStatusToWatching(mutation);
92+
if (!(!isAiring && j === recordContainer.length - 1)) {
93+
mutation = changeStatusToWatching(mutation);
94+
}
8995

9096
const count = i - j;
9197
const recordContainers: NodeListOf<HTMLElement> =
@@ -102,7 +108,7 @@ export async function createRecordButton() {
102108
// 最終話まで見ている場合は、ステータスを"見た"に変更
103109
if (
104110
!isAiring && // アニメが放送終了
105-
j === document.querySelectorAll(".record-container").length - 1 // 最終話
111+
j === recordContainer.length - 1 // 最終話
106112
) {
107113
mutation += `
108114
updateStatus(

src/record-watch-episode.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,14 @@ function sendRecord() {
8686

8787
let mutation = "mutation{";
8888
// 視聴ステータスが"見てる"以外だった場合、"見てる"に変更
89-
if (data[animeIndex]?.viewerStatusState != "WATCHING") {
89+
if (
90+
data[animeIndex]?.viewerStatusState !== "WATCHING" &&
91+
!(
92+
titleElement?.textContent &&
93+
regex.test(titleElement.textContent) &&
94+
episodeIndex + 1 === dataEpisodes[dataEpisodes.length - 1].number
95+
)
96+
) {
9097
mutation += `
9198
updateStatus(
9299
input:{
@@ -103,7 +110,8 @@ function sendRecord() {
103110
`;
104111
// 最終話だった場合、"見た"に変更
105112
if (
106-
regex.test(titleElement?.textContent || "") && // アニメが放送終了
113+
titleElement?.textContent &&
114+
regex.test(titleElement.textContent) && // アニメが放送終了
107115
episodeIndex + 1 === dataEpisodes[dataEpisodes.length - 1].number // 最終話
108116
) {
109117
mutation += `

0 commit comments

Comments
 (0)