Skip to content

Commit

Permalink
コメントのスレッドを選択するオプションを追加 (#18)
Browse files Browse the repository at this point in the history
* コメントのスレッドを選択するオプションを追加

* パフォーマンス改善
  • Loading branch information
sopisoft authored Dec 18, 2022
1 parent 9291ee6 commit 4c976ca
Show file tree
Hide file tree
Showing 10 changed files with 385 additions and 202 deletions.
9 changes: 6 additions & 3 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,23 @@
"label": "install",
"type": "shell",
"command": "npm",
"args": ["install"]
"args": ["install"],
"problemMatcher": []
},
{
"label": "update",
"type": "shell",
"command": "npm",
"args": ["update"]
"args": ["update"],
"problemMatcher": []
},
{
"label": "build",
"type": "shell",
"group": "build",
"command": "npm",
"args": ["run", "watch"]
"args": ["run", "watch"],
"problemMatcher": []
}
]
}
197 changes: 109 additions & 88 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
"@types/react": "^18.0.26",
"@types/react-dom": "^18.0.9",
"copy-webpack-plugin": "^11.0.0",
"css-loader": "^6.7.2",
"css-loader": "^6.7.3",
"prettier": "^2.8.1",
"sass": "^1.56.2",
"sass": "^1.57.0",
"sass-loader": "^13.2.0",
"style-loader": "^3.3.1",
"ts-loader": "^9.4.2",
Expand Down
31 changes: 23 additions & 8 deletions src/content_script/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,26 @@ export const defaultConfigs: Array<config> = [
value: true,
type: "checkbox",
},
{
key: "投稿者コメント",
value: false,
type: "checkbox",
},
{
key: "通常コメント",
value: true,
type: "checkbox",
},
{
key: "かんたんコメント",
value: false,
type: "checkbox",
},
{
key: "自動スクロールの実行間隔 (ミリ秒)",
value: 120,
type: "number",
},
];

/**
Expand All @@ -59,18 +79,13 @@ export const getConfig = (
callback: (value: string | number | boolean) => void
) => {
chrome.storage.local.get([key]).then((result) => {
const defaultValue = defaultConfigs.find((item) => item.key === key)?.value;
if (result[key] === undefined || null) {
console.log(
`${key} (${result[key]}) ${
defaultConfigs.find((item) => item.key === key)?.value
}`
);
console.log(`${key} (${result[key]}) ${defaultValue}`);
} else {
console.log(key, result[key]);
}
callback(
result[key] ?? defaultConfigs.find((item) => item.key === key)?.value
);
callback(result[key] ?? defaultValue);
});
};

Expand Down
8 changes: 6 additions & 2 deletions src/content_script/play/fire.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ const fire = async (movieId: string, data: string) => {
*/
const setD = (message: string, code: string | null) => {
d.style.display = "block";
code ? (d.innerText = `${message}\n${code}`) : (d.innerHTML = `${message}`);
code
? (d.innerText = `${message}\nエラーコード : ${code}`)
: (d.innerHTML = `${message}`);
container.appendChild(b);
return;
};
Expand All @@ -60,7 +62,9 @@ const fire = async (movieId: string, data: string) => {
} else {
setD("コメントの取得に失敗しました。", null);
}
} else {
}
// サーバーからコメントを取得するとき
else {
// サーバーから動画情報を取得する
chrome.runtime
.sendMessage({
Expand Down
2 changes: 1 addition & 1 deletion src/content_script/play/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ const init = () => {
b.textContent = "サイドバーを閉じる";
b.setAttribute("type", "button");
b.addEventListener("click", () => {
b.parentElement?.remove();
container.remove();
});

return { b, s, container, d, video };
Expand Down
Loading

0 comments on commit 4c976ca

Please sign in to comment.