aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/content.ts
diff options
context:
space:
mode:
authorAjay Ramachandran <[email protected]>2021-07-29 20:20:24 -0400
committerGitHub <[email protected]>2021-07-29 20:20:24 -0400
commit2373b3406787c38b68a9acbf9fa4c2e8ab1a7cf8 (patch)
treed22144ef23a101944a5a104ddb177f14703f448b /src/content.ts
parent1656fae2d4113264400d0da4eb956fc6824fb7cf (diff)
parent839dd4613c44f16455121f8a1b7d8f24dd35a6ff (diff)
downloadSponsorBlock-2373b3406787c38b68a9acbf9fa4c2e8ab1a7cf8.tar.gz
SponsorBlock-2373b3406787c38b68a9acbf9fa4c2e8ab1a7cf8.zip
Merge pull request #862 from ajayyy/warning-chat
Add chat box when getting a warning
Diffstat (limited to 'src/content.ts')
-rw-r--r--src/content.ts18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/content.ts b/src/content.ts
index e0f0572e..6320249a 100644
--- a/src/content.ts
+++ b/src/content.ts
@@ -13,7 +13,7 @@ import SkipNotice from "./render/SkipNotice";
import SkipNoticeComponent from "./components/SkipNoticeComponent";
import SubmissionNotice from "./render/SubmissionNotice";
import { Message, MessageResponse } from "./messageTypes";
-import GenericNotice from "./render/GenericNotice";
+import * as Chat from "./js-components/chat";
// Hack to get the CSS loaded on permission-based sites (Invidious)
utils.wait(() => Config.config !== null, 5000, 10).then(addCSS);
@@ -1458,7 +1458,15 @@ function vote(type: number, UUID: string, category?: string, skipNotice?: SkipNo
//success (treat rate limits as a success)
skipNotice.afterVote.bind(skipNotice)(utils.getSponsorTimeFromUUID(sponsorTimes, UUID), type, category);
} else if (response.successType == -1) {
- skipNotice.setNoticeInfoMessage.bind(skipNotice)(utils.getErrorMessage(response.statusCode, response.responseText))
+ if (response.statusCode === 403 && response.responseText.startsWith("Vote rejected due to a warning from a moderator.")) {
+ skipNotice.setNoticeInfoMessageWithOnClick.bind(skipNotice)(() => {
+ Chat.openWarningChat(response.responseText);
+ skipNotice.closeListener.call(skipNotice);
+ }, chrome.i18n.getMessage("voteRejectedWarning"));
+ } else {
+ skipNotice.setNoticeInfoMessage.bind(skipNotice)(utils.getErrorMessage(response.statusCode, response.responseText))
+ }
+
skipNotice.resetVoteButtonInfo.bind(skipNotice)();
}
}
@@ -1567,7 +1575,11 @@ async function sendSubmitMessage() {
playerButtons.submit.button.style.animation = "unset";
playerButtons.submit.image.src = chrome.extension.getURL("icons/PlayerUploadFailedIconSponsorBlocker.svg");
- alert(utils.getErrorMessage(response.status, response.responseText));
+ if (response.status === 403 && response.responseText.startsWith("Submission rejected due to a warning from a moderator.")) {
+ Chat.openWarningChat(response.responseText);
+ } else {
+ alert(utils.getErrorMessage(response.status, response.responseText));
+ }
}
}