Skip to content

Commit

Permalink
1.2.70
Browse files Browse the repository at this point in the history
  • Loading branch information
leomotors committed May 9, 2022
1 parent 7c74f55 commit 51a5c23
Show file tree
Hide file tree
Showing 12 changed files with 797 additions and 809 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ name: Publish Release

on:
push:
branches:
- main
tags:
- "*.*"

jobs:
main:
Expand All @@ -19,3 +19,5 @@ jobs:
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_TITLE: "Anime Captcha {VERSION}"
VERSION_MUST_INCREASE: true
TAG: ${{ github.ref }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ src/config.ts
.vercel

.env

*.g.*
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@

All change except updating data will be noted here

## [1.1.64] - 2022-03-10
## [1.2.70] - 2022-05-09

- Added PWA

- [Breaking] `loli` category now renamed to `fbi`

- Removed Filter in /api/get

## [1.1.62] - 2022-03-10

- Bump Dependencies
Expand Down
15 changes: 3 additions & 12 deletions api/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,16 @@ export default (req: VercelRequest, res: VercelResponse) => {
let category = req.query.category;
if (typeof category == "object") category = category[0];

let filter = req.query.filter;
if (typeof filter == "string") filter = [filter];

let ignoreSize: string | string[] | boolean = req.query.ignoreSize;
if (typeof ignoreSize == "object") ignoreSize = ignoreSize[0];
ignoreSize = ignoreSize?.toLowerCase().includes("true") || +ignoreSize > 0;

if (category) {
const questions = getQuestions(category, filter, ignoreSize);
const questions = getQuestions(category);

if (typeof questions == "string") {
res.status(400).send(questions);
} else if (questions) {
if (questions) {
res.status(200).json(questions);
} else {
res.status(400).send("Invalid Category");
}
} else {
const questions = getRandomQuestions(filter, ignoreSize);
const questions = getRandomQuestions();

if (questions) {
res.status(200).json(questions);
Expand Down
36 changes: 8 additions & 28 deletions data/data.ts
Original file line number Diff line number Diff line change
@@ -1,35 +1,20 @@
import { CaptchaType, CaptchaTypeJSON } from "../src/models/CaptchaType";
import { filterQuestions, parseFilter } from "./filter";

// * Import all JSON Files Here
import * as loli from "./loli.json";
import * as fbi from "./fbi.json";
import * as trap from "./trap.json";

const Data: { [category: string]: CaptchaTypeJSON } = { loli, trap };
const Data: { [category: string]: CaptchaTypeJSON } = { fbi, trap };

// * loli and trap has equal weight (hani is removed)
// * fbi and trap has equal weight (hani is removed)
export const weights = [0, 1, 2];

export function getQuestions(
category: string,
filterOption: string[] = [],
ignoreSize = false
): CaptchaType | string {
export function getQuestions(category: string): CaptchaType | undefined {
const data = Data[category];

if (!data) return "Invalid Category!";
if (!data) return undefined;

const filteredQuestion = filterQuestions(
data.questions,
parseFilter(filterOption)
);

if (filteredQuestion.length < 16 && !ignoreSize)
return "Your filter is too strict, the amount of question after filter must be atleast 16!";

const questions = filteredQuestion
.sort(() => 0.5 - Math.random())
.slice(0, 16);
const questions = data.questions.sort(() => 0.5 - Math.random()).slice(0, 16);

return {
category,
Expand All @@ -45,16 +30,11 @@ function getCategoryByIndex(index: number): number {
}
}

export function getRandomQuestions(
filterOption: string[] = [],
ignoreSize = false
): CaptchaType | undefined {
export function getRandomQuestions(): CaptchaType | undefined {
const category_index = Math.random() * weights[weights.length - 1];
const category = Object.keys(Data)[getCategoryByIndex(category_index)];

const res = getQuestions(category, filterOption, ignoreSize);
if (typeof res == "string") return undefined;
return res;
return getQuestions(category);
}

export function getAll() {
Expand Down
12 changes: 12 additions & 0 deletions data/loli.json → data/fbi.json
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,18 @@
"ja": "幼なじみが絶対に負けないラブコメ"
},
"answer": false
},
{
"image": "https://github.com/Leomotors/anime-captcha/blob/main/images/aharen_ren.webp?raw=true",
"name": {
"en": "Aharen Ren",
"ja": "阿波連れん"
},
"anime": {
"en": "Aharen-san Is Indecipherable",
"ja": "阿波連さんははかれない"
},
"answer": false
}
],
"onFail": {
Expand Down
82 changes: 0 additions & 82 deletions data/filter.ts

This file was deleted.

24 changes: 24 additions & 0 deletions data/trap.json
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,30 @@
"ja": "進撃の巨人"
},
"answer": false
},
{
"image": "https://github.com/Leomotors/anime-captcha/blob/main/images/aharen_ren.webp?raw=true",
"name": {
"en": "Aharen Ren",
"ja": "阿波連れん"
},
"anime": {
"en": "Aharen-san Is Indecipherable",
"ja": "阿波連さんははかれない"
},
"answer": false
},
{
"image": "https://newsdio.com/wp-content/uploads/2021/09/Looper-3-1.jpg",
"name": {
"en": "Aharen Reina",
"ja": "阿波連れいな"
},
"anime": {
"en": "Aharen-san Is Indecipherable",
"ja": "阿波連さんははかれない"
},
"answer": true
}
],
"onFail": {
Expand Down
Binary file added images/aharen_ren.webp
Binary file not shown.
28 changes: 14 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "anime-captcha",
"version": "1.2.69",
"version": "1.2.70",
"type": "module",
"scripts": {
"dev": "lm-config && vite --port $PORT",
Expand All @@ -19,22 +19,22 @@
},
"homepage": "https://github.com/Leomotors/anime-captcha",
"devDependencies": {
"@leomotors/scripts": "^3.0.7",
"@sveltejs/vite-plugin-svelte": "^1.0.0-next.40",
"@typescript-eslint/eslint-plugin": "^5.15.0",
"@typescript-eslint/parser": "^5.15.0",
"@vercel/node": "^1.13.0",
"@leomotors/scripts": "^3.1.0",
"@sveltejs/vite-plugin-svelte": "^1.0.0-next.43",
"@typescript-eslint/eslint-plugin": "^5.22.0",
"@typescript-eslint/parser": "^5.22.0",
"@vercel/node": "^1.15.0",
"bootstrap": "^5.1.3",
"chalk": "^5.0.1",
"eslint": "^8.11.0",
"eslint": "^8.15.0",
"node-sass": "^7.0.1",
"svelte": "^3.46.4",
"svelte-check": "^2.4.6",
"svelte-preprocess": "^4.10.4",
"svelte": "^3.48.0",
"svelte-check": "^2.7.0",
"svelte-preprocess": "^4.10.6",
"sveltestrap": "^5.9.0",
"tslib": "^2.3.1",
"typescript": "^4.6.2",
"vite": "^2.8.6",
"vite-plugin-pwa": "^0.11.13"
"tslib": "^2.4.0",
"typescript": "^4.6.4",
"vite": "^2.9.8",
"vite-plugin-pwa": "^0.12.0"
}
}
2 changes: 1 addition & 1 deletion src/components/FooterBar.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import { Version, BuildTime } from "../config";
import { Version, BuildTime } from "../config.g";
import { onMount } from "svelte";
let ageLabel: string;
Expand Down
Loading

1 comment on commit 51a5c23

@vercel
Copy link

@vercel vercel bot commented on 51a5c23 May 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

anime-captcha – ./

anime-captcha-git-main-leomotors.vercel.app
anime-captcha-leomotors.vercel.app
anime-captcha.vercel.app

Please sign in to comment.