From 136087d83e1427f5daa35b51a10abc2b511125d0 Mon Sep 17 00:00:00 2001 From: neobooru <50623835+neobooru@users.noreply.github.com> Date: Fri, 12 Aug 2022 00:39:24 +0200 Subject: [PATCH] Add support for multiple sources - Add the "Add page URL to the source list" option --- package.json | 11 +++++---- scripts/{build-zip.js => build-zip.cjs} | 0 scripts/{sign-xpi.js => sign-xpi.cjs} | 0 src/Config.ts | 2 +- src/ViewModels.ts | 14 +++++++---- src/css/style.css | 17 ++++++++++++-- src/options/App.vue | 15 ++++++------ src/popup/App.vue | 31 ++++++++++++++----------- src/scripts/content.ts | 2 +- webpack.common.js => webpack.common.cjs | 0 webpack.dev.js => webpack.dev.cjs | 14 +++++------ webpack.prod.js => webpack.prod.cjs | 2 +- yarn.lock | 2 +- 13 files changed, 67 insertions(+), 43 deletions(-) rename scripts/{build-zip.js => build-zip.cjs} (100%) rename scripts/{sign-xpi.js => sign-xpi.cjs} (100%) rename webpack.common.js => webpack.common.cjs (100%) rename webpack.dev.js => webpack.dev.cjs (50%) rename webpack.prod.js => webpack.prod.cjs (68%) diff --git a/package.json b/package.json index 3a309f3..08ea8e8 100644 --- a/package.json +++ b/package.json @@ -7,12 +7,13 @@ "repository": { "url": "https://github.com/neobooru/SzuruChrome" }, + "type": "module", "scripts": { - "build": "webpack --config webpack.prod.js", - "build:dev": "webpack --config webpack.dev.js", - "build-zip": "node scripts/build-zip.js", - "sign-xpi": "node scripts/sign-xpi.js", - "watch": "webpack --watch --config webpack.dev.js", + "build": "webpack --config webpack.prod.cjs", + "build:dev": "webpack --config webpack.dev.cjs", + "build-zip": "node scripts/build-zip.cjs", + "sign-xpi": "node scripts/sign-xpi.cjs", + "watch": "webpack --watch --config webpack.dev.cjs", "lint": "eslint src" }, "dependencies": { diff --git a/scripts/build-zip.js b/scripts/build-zip.cjs similarity index 100% rename from scripts/build-zip.js rename to scripts/build-zip.cjs diff --git a/scripts/sign-xpi.js b/scripts/sign-xpi.cjs similarity index 100% rename from scripts/sign-xpi.js rename to scripts/sign-xpi.cjs diff --git a/src/Config.ts b/src/Config.ts index c90a702..628f42e 100644 --- a/src/Config.ts +++ b/src/Config.ts @@ -10,7 +10,7 @@ export class Config { importExistingTags = true; importAllTags = false; importCommentary = false; - useOriginalSource = true; + addPageUrlToSource = true; autoSearchSimilar = false; loadTagCounts = true; useContentTokens = true; diff --git a/src/ViewModels.ts b/src/ViewModels.ts index 35d0c91..b56616c 100644 --- a/src/ViewModels.ts +++ b/src/ViewModels.ts @@ -10,7 +10,7 @@ export class TagViewModel { const x = new TagViewModel(tag.names[0], tag.category, tag.usages); if (tag.implications) { - x.implications = tag.implications.map(y => TagViewModel.fromMicroTag(y)); + x.implications = tag.implications.map((y) => TagViewModel.fromMicroTag(y)); } return x; @@ -34,7 +34,7 @@ export class PostViewModel { pageUrl: string; contentType: ContentType; rating: BooruTypes.SafetyRating; - source: string | undefined; + source = ""; referrer: string | undefined; resolution: [number, number] | undefined; @@ -43,9 +43,15 @@ export class PostViewModel { this.pageUrl = post.pageUrl; this.contentType = post.contentType; this.rating = post.rating; - this.source = post.source; + + if (post.sources.length > 0) { + // Add extra newline at the end for user convenience. This allows the user to click below the last source line to add something. + // But we only do this if there is at least one source, otherwise we get a blank line when there are zero sources. + this.source = post.sources.join("\n") + "\n"; + } + this.referrer = post.referrer; - this.tags = post.tags.map(x => TagViewModel.fromScapedTag(x)); + this.tags = post.tags.map((x) => TagViewModel.fromScapedTag(x)); this.notes = post.notes; this.resolution = post.resolution; } diff --git a/src/css/style.css b/src/css/style.css index 252d0ba..fbc8b74 100644 --- a/src/css/style.css +++ b/src/css/style.css @@ -21,17 +21,30 @@ button.primary { } input[type="text"] { + height: 26px; +} + +input[type="text"], +textarea { background-color: #fafafa; border: 1px solid #eee; - height: 26px; width: 100%; } -input[type="text"]:focus { +input[type="text"]:focus, +textarea:focus { outline: #24aadd solid 2px; box-sizing: content-box; } +textarea { + white-space: pre; + overflow-wrap: normal; + overflow-x: scroll; + text-overflow: ellipsis; + resize: vertical; +} + img { max-width: 100%; max-height: 100%; diff --git a/src/options/App.vue b/src/options/App.vue index d1af996..d97c0c3 100644 --- a/src/options/App.vue +++ b/src/options/App.vue @@ -29,12 +29,13 @@
  • - Use the original image source when available. Usually this will mean a Twitter, DeviantArt, ArtStation, or - Pixiv page. + This will add the current page URL (e.g. the booru link) to the source list in addition to the actual source + (e.g. twitter/pixiv/artstation). Note: if the source is empty/not detected then the page URL will always be + used as fallback source.

  • @@ -74,7 +75,7 @@ export default Vue.extend({ authToken: "", autoSearchSimilar: false, loadTagCounts: false, - useOriginalSource: false, + addPageUrlToSource: false, useContentTokens: false, statusText: "", statusType: "", @@ -114,7 +115,7 @@ export default Vue.extend({ config.sites = [siteConfig]; config.autoSearchSimilar = this.autoSearchSimilar; config.loadTagCounts = this.loadTagCounts; - config.useOriginalSource = this.useOriginalSource; + config.addPageUrlToSource = this.addPageUrlToSource; config.useContentTokens = this.useContentTokens; await config.save(); @@ -140,7 +141,7 @@ export default Vue.extend({ this.autoSearchSimilar = config.autoSearchSimilar; this.loadTagCounts = config.loadTagCounts; - this.useOriginalSource = config.useOriginalSource; + this.addPageUrlToSource = config.addPageUrlToSource; this.useContentTokens = config.useContentTokens; }, }); diff --git a/src/popup/App.vue b/src/popup/App.vue index 9d80d36..0c78274 100644 --- a/src/popup/App.vue +++ b/src/popup/App.vue @@ -43,7 +43,7 @@
    - +