diff --git a/package.json b/package.json index 478da4d..cd8e493 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "szuru-chrome", - "version": "0.6.4", + "version": "0.7.0", "description": "Import media from various sites into szurubooru.", "author": "neobooru", "license": "MIT", @@ -16,7 +16,7 @@ }, "dependencies": { "axios": "^0.21.1", - "neo-scraper": "^0.4.3", + "neo-scraper": "^0.4.4", "vue": "^2.6.11", "webextension-polyfill": "^0.3.1" }, diff --git a/src/Common.ts b/src/Common.ts index 9baf203..d357675 100644 --- a/src/Common.ts +++ b/src/Common.ts @@ -34,3 +34,9 @@ export function getUrl(root: string, ...parts: string[]): string { export function isChrome() { return /Chrome/.test(navigator.userAgent); } + +export function encodeTagName(tagName: string) { + // Searching for posts with re:zero will show an error message about unknown named token. + // Searching for posts with re\:zero will show posts tagged with re:zero. + return tagName.replace(/\:/g, "\\:"); +} diff --git a/src/Config.ts b/src/Config.ts index ae9cf7a..69b2090 100644 --- a/src/Config.ts +++ b/src/Config.ts @@ -12,6 +12,7 @@ export class Config { importCommentary: boolean = false; useOriginalSource: boolean = true; autoSearchSimilar: boolean = false; + loadTagCounts: boolean = true; sites: Array = []; public async save() { diff --git a/src/SzuruTypes.ts b/src/SzuruTypes.ts index e1e3706..70e8350 100644 --- a/src/SzuruTypes.ts +++ b/src/SzuruTypes.ts @@ -13,6 +13,11 @@ export interface SzuruError { description: string; } +export interface PostAlreadyUploadedError extends SzuruError { + otherPostId: number; + otherPostUrl: string; +} + export interface PagedSearchResult { query: string; offset: number; diff --git a/src/SzuruWrapper.ts b/src/SzuruWrapper.ts index 0a1abc9..4c6f984 100644 --- a/src/SzuruWrapper.ts +++ b/src/SzuruWrapper.ts @@ -40,12 +40,13 @@ export default class SzuruWrapper { return (await this.apiPut("tag/" + tag.names[0], tag)).data; } - async getTags(query: string): Promise { - let url = "tags"; + async getTags(query: string, offset: number = 0): Promise { + const params = new URLSearchParams(); + params.append("offset", offset.toString()); if (query) { - url += query; + params.append("query", query); } - return (await this.apiGet(url)).data; + return (await this.apiGet("tags?" + params.toString())).data; } async getTagCategories(): Promise { @@ -82,7 +83,7 @@ export default class SzuruWrapper { }; config.headers = { ...this.baseHeaders, ...additionalHeaders }; - return await this.execute(config); + return this.execute(config); } private async apiPost(url: string, data: any, additionalHeaders: any = {}): Promise { @@ -94,7 +95,7 @@ export default class SzuruWrapper { }; config.headers = { ...this.baseHeaders, ...additionalHeaders }; - return await this.execute(config); + return this.execute(config); } private async apiPut(url: string, data: any, additionalHeaders: any = {}): Promise { @@ -106,14 +107,13 @@ export default class SzuruWrapper { }; config.headers = { ...this.baseHeaders, ...additionalHeaders }; - return await this.execute(config); + return this.execute(config); } private async execute(config: AxiosRequestConfig): Promise { if (this.username && this.authToken) { const token = "Token " + btoa(`${this.username}:${this.authToken}`); config.headers["Authorization"] = token; - // console.log(token); } try { diff --git a/src/options/App.vue b/src/options/App.vue index 35dceba..ee5334f 100644 --- a/src/options/App.vue +++ b/src/options/App.vue @@ -32,6 +32,11 @@
+ +