diff --git a/assets/js/repostHelper.js b/assets/js/repostHelper.js index 0edb5e2..72e792f 100644 --- a/assets/js/repostHelper.js +++ b/assets/js/repostHelper.js @@ -40,12 +40,7 @@ repostForm.addEventListener('submit', async (e) => { pushToast("Invalid post URL", false); showRepostProgress(false); } - try { - new URL(postRecordVal); - } catch(urlErr) { - invalidPostURL(); - return; - } + let dateTime; try { dateTime = new Date(scheduledDateVal).toISOString(); @@ -54,28 +49,34 @@ repostForm.addEventListener('submit', async (e) => { showRepostProgress(false); return; } - const postObject = { scheduledDate: dateTime, data: { - type: 0 + type: REPOST_TYPE_NONE } }; if (existingPostId.hasAttribute("data-id")) { postObject.data = { - type: 2, + type: REPOST_TYPE_FUTURE, id: existingPostId.getAttribute("data-id") } } else { postObject.data = { - url: postRecordVal, - type: 1 + type: REPOST_TYPE_EXISTING, + url: postRecordVal }; // Push any names we have for the post here too if (repostTitle.value !== "" && isElementVisible(repostTitleSection)) { postObject.data.content = repostTitle.value; } + try { + if (isElementVisible(retweetFields)) + new URL(postRecordVal); + } catch(urlErr) { + invalidPostURL(); + return; + } // Check to see if url can match with our regex if (!ATPROTO_RECORD_REGEX.test(postRecordVal)) { invalidPostURL(); diff --git a/src/statics/appScripts.ts b/src/statics/appScripts.ts index 5a1e199..fb78509 100644 --- a/src/statics/appScripts.ts +++ b/src/statics/appScripts.ts @@ -1,6 +1,6 @@ // Change this value to break out of any caching that might be happening // for the runtime scripts (ex: main.js & postHelper.js) -export const CURRENT_SCRIPT_VERSION: string = "2.0.8"; +export const CURRENT_SCRIPT_VERSION: string = "2.0.9"; const getAppScriptStr = (scriptName: string) => `/js/min/${scriptName}.min.js?v=${CURRENT_SCRIPT_VERSION}`; diff --git a/src/statics/constScript.ts b/src/statics/constScript.ts index abd9f6b..d427024 100644 --- a/src/statics/constScript.ts +++ b/src/statics/constScript.ts @@ -1,5 +1,5 @@ import { POSTING_TIME_INTERVAL, REPOSTING_TIME_INTERVAL } from "../config"; -import { EmbedDataType } from "../enums"; +import { EmbedDataType, RepostType } from "../enums"; import { ACCOUNT_EXPIRE_FORCE_LOGOUT, BSKY_GIF_MIME_TYPES, BSKY_IMG_MIME_TYPES, @@ -13,7 +13,7 @@ import { } from "../limits"; import { postRecordURI } from "../validation/regexCases"; -export const CONST_SCRIPT_VERSION: number = 14; +export const CONST_SCRIPT_VERSION: number = 15; export const constScriptStr: string = `/js/consts.js?v=${CONST_SCRIPT_VERSION}`; export function makeConstScript(): string { @@ -46,9 +46,14 @@ const FILE_DROP_MAX_FILES=${MAX_FILES_PER_POST}; const ATPROTO_RECORD_REGEX=${postRecordURI}; const POSTING_TIME_INTERVAL=${POSTING_TIME_INTERVAL}; const REPOSTING_TIME_INTERVAL=${REPOSTING_TIME_INTERVAL}; +/* EmbedDataType enum */ const IMAGE_DATA_TYPE=${EmbedDataType.Image}; const VIDEO_DATA_TYPE=${EmbedDataType.Video}; const WEBLINK_DATA_TYPE=${EmbedDataType.WebLink}; const RECORD_DATA_TYPE=${EmbedDataType.Record}; +/* RepostType enum */ +const REPOST_TYPE_NONE=${RepostType.None}; +const REPOST_TYPE_EXISTING=${RepostType.ExistingPost}; +const REPOST_TYPE_FUTURE=${RepostType.FuturePost}; const ACCOUNT_EXPIRE_TIMEOUT=${Math.abs(ACCOUNT_EXPIRE_FORCE_LOGOUT)};`; }