From 7a948fcd267a6a355a0a12fd6ed9c9af4d2b26cb Mon Sep 17 00:00:00 2001
From: Nutthapat Pongtanyavichai <59821765+Leomotors@users.noreply.github.com>
Date: Thu, 19 May 2022 19:24:01 +0700
Subject: [PATCH] Add Debug and Characters
---
.gitattributes | 1 +
.github/workflows/codeql-analysis.yml | 70 +++++++++++++++++++++
CHANGELOG.md | 4 ++
CONTRIBUTING.md | 8 +++
package.json | 4 +-
prebuild.js | 4 +-
src/app.css | 12 ++++
src/data/fbi.json | 60 ++++++++++++++++++
src/data/model.ts | 2 +
src/data/trap.json | 24 ++++++++
src/routes/answerkey.svelte | 4 +-
src/routes/debug.svelte | 87 +++++++++++++++++++++++++++
src/routes/statistics.svelte | 3 +-
13 files changed, 276 insertions(+), 7 deletions(-)
create mode 100644 .gitattributes
create mode 100644 .github/workflows/codeql-analysis.yml
create mode 100644 src/routes/debug.svelte
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..bceb2f8
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1 @@
+src/app.d.ts linguist-vendored=false
diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml
new file mode 100644
index 0000000..7babe33
--- /dev/null
+++ b/.github/workflows/codeql-analysis.yml
@@ -0,0 +1,70 @@
+# For most projects, this workflow file will not need changing; you simply need
+# to commit it to your repository.
+#
+# You may wish to alter this file to override the set of languages analyzed,
+# or to provide custom queries or build logic.
+#
+# ******** NOTE ********
+# We have attempted to detect the languages in your repository. Please check
+# the `language` matrix defined below to confirm you have the correct set of
+# supported CodeQL languages.
+#
+name: "CodeQL"
+
+on:
+ push:
+ branches: [ main ]
+ pull_request:
+ # The branches below must be a subset of the branches above
+ branches: [ main ]
+
+jobs:
+ analyze:
+ name: Analyze
+ runs-on: ubuntu-latest
+ permissions:
+ actions: read
+ contents: read
+ security-events: write
+
+ strategy:
+ fail-fast: false
+ matrix:
+ language: [ 'javascript' ]
+ # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
+ # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
+
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v3
+
+ # Initializes the CodeQL tools for scanning.
+ - name: Initialize CodeQL
+ uses: github/codeql-action/init@v2
+ with:
+ languages: ${{ matrix.language }}
+ # If you wish to specify custom queries, you can do so here or in a config file.
+ # By default, queries listed here will override any specified in a config file.
+ # Prefix the list here with "+" to use these queries and those in the config file.
+
+ # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
+ # queries: security-extended,security-and-quality
+
+
+ # Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
+ # If this step fails, then you should remove it and run the build manually (see below)
+ - name: Autobuild
+ uses: github/codeql-action/autobuild@v2
+
+ # ℹ️ Command-line programs to run using the OS shell.
+ # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
+
+ # If the Autobuild fails above, remove it and uncomment the following three lines.
+ # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
+
+ # - run: |
+ # echo "Run, Build Application using script"
+ # ./location_of_script_within_repo/buildscript.sh
+
+ - name: Perform CodeQL Analysis
+ uses: github/codeql-action/analyze@v2
diff --git a/CHANGELOG.md b/CHANGELOG.md
index acdee0c..da3ab1e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,10 @@
All change except updating data will be noted here
+## [1.3.136] - 2022-05-19
+
+- Added /debug (Accessible in development only)
+
## [1.3.132] - 2022-05-19
- Add History (in /statistics)
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index f84f623..92254a7 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -39,3 +39,11 @@ now but if set correctly, will appear once pushed)
```
https://github.com/Leomotors/anime-captcha/blob/main/images/Armin.webp?raw=true
```
+
+### Local Testing
+
+Start the app in development mode at visits /debug
+
+This will display all the images **and their answer** (Spoiler Warning)
+
+Please make sure your image is accessible from browser and not blocked by CORS or anything.
diff --git a/package.json b/package.json
index e613a6c..f05d8f1 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "anime-captcha",
- "version": "1.3.132",
+ "version": "1.3.136",
"type": "module",
"repository": {
"type": "git",
@@ -51,4 +51,4 @@
"typescript": "^4.6.4",
"vite-plugin-pwa": "^0.12.0"
}
-}
+}
\ No newline at end of file
diff --git a/prebuild.js b/prebuild.js
index 2792e13..d868f72 100644
--- a/prebuild.js
+++ b/prebuild.js
@@ -37,14 +37,14 @@ for (const file of files) {
fs.writeFile(
"./src/data/data.g.ts",
`
-import type { CaptchaTypeJSON } from "$data/model";
+import type { CaptchaGetAll } from "$data/model";
${categories.reduce(
(prev, cate) => prev + `import * as ${cate} from "./${cate}.json";\n`,
""
)}
-export const Data: { [category: string]: CaptchaTypeJSON } = { ${categories} };
+export const Data: CaptchaGetAll = { ${categories} };
`
);
diff --git a/src/app.css b/src/app.css
index 385c705..7a3a64c 100644
--- a/src/app.css
+++ b/src/app.css
@@ -45,3 +45,15 @@ button,
iframe {
@apply select-none;
}
+
+.captcha-table {
+ @apply table-auto border-collapse border-[1.5px] border-slate-900;
+}
+
+.captcha-table > thead {
+ @apply border-b-[1.5px] border-black;
+}
+
+.captcha-table > thead > tr > th {
+ @apply p-2;
+}
diff --git a/src/data/fbi.json b/src/data/fbi.json
index 6d61dc4..0411ad0 100644
--- a/src/data/fbi.json
+++ b/src/data/fbi.json
@@ -744,6 +744,66 @@
"ja": "阿波連さんははかれない"
},
"answer": false
+ },
+ {
+ "image": "https://i.pinimg.com/originals/7d/f6/b3/7df6b334ee6a8457b6ba8aaf2f81fdd8.jpg",
+ "name": {
+ "en": "Falco Grice",
+ "ja": "ファルコ・グライス"
+ },
+ "anime": {
+ "en": "Attack on Titan",
+ "ja": "進撃の巨人"
+ },
+ "answer": false
+ },
+ {
+ "image": "https://i.pinimg.com/736x/10/c9/c0/10c9c02224ae9c08ba781bae2a856675.jpg",
+ "name": {
+ "en": "Anya Forger",
+ "ja": "アーニャ・フォージャー"
+ },
+ "anime": {
+ "en": "SPY×FAMILY",
+ "ja": "スパイファミリー"
+ },
+ "answer": false
+ },
+ {
+ "image": "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTdRo7bOi2DRI5OaO5n0T8UVpidUQRyXWwalw&usqp=CAU",
+ "name": {
+ "en": "Loid Forger",
+ "ja": "ロイド・フォージャー"
+ },
+ "anime": {
+ "en": "SPY×FAMILY",
+ "ja": "スパイファミリー"
+ },
+ "answer": true
+ },
+ {
+ "image": "https://cdn.realsport101.com/images/ncavvykf/epicstream/e31e80a44efa30c13576b0d29d1a1b13a7428f26-1200x628.jpg?rect=42,0,1116,628&w=700&h=394&dpr=2",
+ "name": {
+ "en": "Yor Forger",
+ "ja": "ヨル・フォージャー"
+ },
+ "anime": {
+ "en": "SPY×FAMILY",
+ "ja": "スパイファミリー"
+ },
+ "answer": true
+ },
+ {
+ "image": "https://i.pinimg.com/236x/ff/08/73/ff0873326996049d257fb08928fa5c80.jpg",
+ "name": {
+ "en": "Izumi Motoko",
+ "ja": "和泉許子"
+ },
+ "anime": {
+ "en": "Shikimori's Not Just a Cutie",
+ "ja": "可愛いだけじゃない式守さん"
+ },
+ "answer": true
}
],
"onFail": {
diff --git a/src/data/model.ts b/src/data/model.ts
index bcb068e..971e220 100644
--- a/src/data/model.ts
+++ b/src/data/model.ts
@@ -31,3 +31,5 @@ export interface CaptchaType extends CaptchaTypeJSON {
// * Short name of Title
category: string;
}
+
+export type CaptchaGetAll = { [category: string]: CaptchaTypeJSON };
diff --git a/src/data/trap.json b/src/data/trap.json
index b1a09ee..f6e1f2e 100644
--- a/src/data/trap.json
+++ b/src/data/trap.json
@@ -660,6 +660,30 @@
"ja": "阿波連さんははかれない"
},
"answer": true
+ },
+ {
+ "image": "https://i.ytimg.com/vi/ydvzdAMm7cM/maxresdefault.jpg",
+ "name": {
+ "en": "Shikimori",
+ "ja": "式守さん"
+ },
+ "anime": {
+ "en": "Shikimori's Not Just a Cutie",
+ "ja": "可愛いだけじゃない式守さん"
+ },
+ "answer": true
+ },
+ {
+ "image": "https://external-preview.redd.it/MMWh9renmFzqxS9rwZW59LwqWCxBGp_p1IqZK-PnbM4.jpg?width=640&crop=smart&auto=webp&s=759e0dc3f98400538a0b4f6ce4eab5119cab3a3d",
+ "name": {
+ "en": "Izumi",
+ "ja": "和泉くん"
+ },
+ "anime": {
+ "en": "Shikimori's Not Just a Cutie",
+ "ja": "可愛いだけじゃない式守さん"
+ },
+ "answer": false
}
],
"onFail": {
diff --git a/src/routes/answerkey.svelte b/src/routes/answerkey.svelte
index 150230d..d001a35 100644
--- a/src/routes/answerkey.svelte
+++ b/src/routes/answerkey.svelte
@@ -28,8 +28,8 @@
Result of "{play.dataset.title.replace(/<[^>]+>/g, " ").trim()}"
-
-
+
+
Image
Character Name
diff --git a/src/routes/debug.svelte b/src/routes/debug.svelte
new file mode 100644
index 0000000..09face4
--- /dev/null
+++ b/src/routes/debug.svelte
@@ -0,0 +1,87 @@
+
+
+
+
+
+ Insight created at {insight.created_at}
+
+ {#each Object.entries(data) as [cate, captcha]}
+ Category: {cate}
+
+
+
+ Category
+ Index
+ Image
+ Character Name
+ Anime
+
+
+
+ {#each captcha.questions as question, index}
+
+ {cate}
+ {index + 1}
+
+
+
+
+
+
+ {/each}
+
+
+
+ Correct Ratio: {I(cate).correct_count}/{I(cate).questions_count} ({I(cate)
+ .correct_ratio})
+
+ {/each}
+
+
+
diff --git a/src/routes/statistics.svelte b/src/routes/statistics.svelte
index 8519f0e..0701608 100644
--- a/src/routes/statistics.svelte
+++ b/src/routes/statistics.svelte
@@ -28,7 +28,8 @@
- Note: The history is stored in your browser's LocalStorage
+ Note: The history is stored in your browser's LocalStorage, only the last
+ 100 plays are kept.