Skip to content

Commit 9e07ee1

Browse files
shibaobunneobooru
authored andcommitted
add alwaysUploadAsContent option
1 parent 7c5c4d3 commit 9e07ee1

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

src/options/App.vue

+11
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,17 @@ wnd.szc_set_config_version = (v = 0) => (cfg.value.version = v);
139139
</p>
140140
</div>
141141

142+
<div class="col-12 md:col-6">
143+
<label>
144+
<input type="checkbox" v-model="cfg.alwaysUploadAsContent" />
145+
Always upload as content
146+
</label>
147+
<p class="hint">
148+
This will always upload the image content directly, instead of
149+
as an URL
150+
</p>
151+
</div>
152+
142153
<span class="col-12 status-quiet">{{ versionInfo }}</span>
143154
</div>
144155
</TabPanel>

src/popup/pages/PopupMain.vue

+11-4
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,12 @@ async function upload() {
162162
try {
163163
const post: ScrapedPostDetails = cloneDeep(pop.selectedPost)!;
164164
165-
// uploadMode "content" requires a content token to work. So ensure it is set.
166-
if (post.uploadMode == "content") {
165+
// uploadMode "content" requires a content token to work. So ensure it is
166+
// set. Ignore fallback "Upload as URL" mode as well
167+
if (
168+
(cfg.value.alwaysUploadAsContent || post.uploadMode === "content")
169+
&& post.name !== "[fallback] Upload as URL"
170+
) {
167171
await ensurePostHasContentToken(post);
168172
}
169173
@@ -257,7 +261,10 @@ async function ensurePostHasContentToken(post: ScrapedPostDetails) {
257261
}
258262
259263
try {
260-
let tmpRes = await selectedInstance.uploadTempFile(post.contentUrl, post.uploadMode);
264+
const uploadMode =
265+
cfg.value.alwaysUploadAsContent && post.name !== "[fallback] Upload as URL" ?
266+
'content' : post.uploadMode;
267+
let tmpRes = await selectedInstance.uploadTempFile(post.contentUrl, uploadMode);
261268
// Save contentToken in PostViewModel so that we can reuse it when creating/uploading the post.
262269
instanceSpecificData.contentToken = tmpRes.token;
263270
} catch (ex) {
@@ -403,7 +410,7 @@ useDark();
403410
<template>
404411
<div class="popup-messages">
405412
<div class="messages">
406-
<!--
413+
<!--
407414
Error messages
408415
-->
409416

src/stores/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export const cfg = useStorageLocal(
1414
{
1515
version: 0,
1616
addPageUrlToSource: true,
17+
alwaysUploadAsContent: false,
1718
autoSearchSimilar: false,
1819
loadTagCounts: true,
1920
fetchPostInfo: true,

0 commit comments

Comments
 (0)