diff --git a/package.json b/package.json index e24acbf..68ed0cf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "szuru-chrome", - "version": "0.1.4", + "version": "0.2.0", "description": "Import media from various sites into szurubooru", "author": "neobooru", "license": "MIT", diff --git a/src/Config.ts b/src/Config.ts index 7e05faf..e88db12 100644 --- a/src/Config.ts +++ b/src/Config.ts @@ -10,6 +10,7 @@ export class Config { importExistingTags: boolean = true; importAllTags: boolean = false; importCommentary: boolean = false; + autoSearchSimilar: boolean = false; sites: Array = []; public async save() { diff --git a/src/SzuruTypes.ts b/src/SzuruTypes.ts index e17cb5b..b07891a 100644 --- a/src/SzuruTypes.ts +++ b/src/SzuruTypes.ts @@ -90,3 +90,13 @@ export interface Post { notes: any[]; // Note resource comments: any[]; // Comment resource } + +export interface SimilarPost { + distance: number; + post: Post; +} + +export interface ImageSearchResult { + exactPost: Post | null; + similarPosts: SimilarPost[]; +} diff --git a/src/SzuruWrapper.ts b/src/SzuruWrapper.ts index b3bf663..ef0706a 100644 --- a/src/SzuruWrapper.ts +++ b/src/SzuruWrapper.ts @@ -1,7 +1,7 @@ import axios, { AxiosRequestConfig } from "axios"; import { ScrapedPost } from "neo-scraper"; import { SzuruSiteConfig } from "./Config"; -import { TagsResult, TagCategoriesResult, Post, Tag, SzuruError } from "./SzuruTypes"; +import { TagsResult, TagCategoriesResult, Post, Tag, SzuruError, ImageSearchResult } from "./SzuruTypes"; /** * A 1:1 wrapper around the szurubooru API. @@ -66,6 +66,14 @@ export default class SzuruWrapper { return (await this.apiPost("posts", obj)).data; } + async reverseSearch(imageUrl: string): Promise { + var obj = { + contentUrl: imageUrl + }; + + return (await this.apiPost("posts/reverse-search", obj)).data; + } + private async apiGet(url: string, additionalHeaders: any = {}): Promise { const fullUrl = this.apiUrl + url; const config: AxiosRequestConfig = { diff --git a/src/css/style.css b/src/css/style.css index 2935e52..d6f021c 100644 --- a/src/css/style.css +++ b/src/css/style.css @@ -12,6 +12,8 @@ button { font-family: "Open Sans", sans-serif; height: 30px; cursor: pointer; + padding: 0 10px; + white-space: nowrap; } button.primary { diff --git a/src/options/App.vue b/src/options/App.vue index 066612d..8c647d7 100644 --- a/src/options/App.vue +++ b/src/options/App.vue @@ -22,6 +22,15 @@
+ +