diff options
author | Ajay Ramachandran <[email protected]> | 2021-07-29 19:16:18 -0400 |
---|---|---|
committer | Ajay Ramachandran <[email protected]> | 2021-07-29 19:16:18 -0400 |
commit | c84a951accfe8bf5bbf632f4cef8a168037359d0 (patch) | |
tree | d6e454df067ee99957b42136490800fd1b269c95 | |
parent | d0949452dac82214f493eca9045ad82b70a064b3 (diff) | |
download | SponsorBlock-c84a951accfe8bf5bbf632f4cef8a168037359d0.tar.gz SponsorBlock-c84a951accfe8bf5bbf632f4cef8a168037359d0.zip |
Add chat for warnings after voting
-rw-r--r-- | public/_locales/en/messages.json | 3 | ||||
-rw-r--r-- | public/content.css | 1 | ||||
-rw-r--r-- | src/components/SkipNoticeComponent.tsx | 14 | ||||
-rw-r--r-- | src/content.ts | 10 | ||||
-rw-r--r-- | src/js-components/chat.ts | 2 |
5 files changed, 22 insertions, 8 deletions
diff --git a/public/_locales/en/messages.json b/public/_locales/en/messages.json index 4a462055..3105f7ed 100644 --- a/public/_locales/en/messages.json +++ b/public/_locales/en/messages.json @@ -678,5 +678,8 @@ }, "warningChatInfo": { "message": "You got a warning and cannot submit segments temporarily. This means that we noticed you were making some common mistakes that are not malicious, and we just want to clarify the rules. You can also join this chat using discord.gg/SponsorBlock or matrix.to/#/+sponsor:ajay.app" + }, + "voteRejectedWarning": { + "message": "Vote rejected due to a warning. Click to open a chat to resolve it, or come back later when you have time." } } diff --git a/public/content.css b/public/content.css index c4c528ae..ba0d7016 100644 --- a/public/content.css +++ b/public/content.css @@ -133,6 +133,7 @@ .sponsorSkipNotice { min-width: 350px; + max-width: 50%; background-color: rgba(28, 28, 28, 0.9); position: absolute; right: 5px; diff --git a/src/components/SkipNoticeComponent.tsx b/src/components/SkipNoticeComponent.tsx index 1582c2c9..f8269e88 100644 --- a/src/components/SkipNoticeComponent.tsx +++ b/src/components/SkipNoticeComponent.tsx @@ -313,11 +313,15 @@ class SkipNoticeComponent extends React.Component<SkipNoticeProps, SkipNoticeSta for (let i = 0; i < this.state.messages.length; i++) { elements.push( - <NoticeTextSelectionComponent idSuffix={this.idSuffix} - text={this.state.messages[i]} - onClick={this.state.messageOnClick} - key={i}> - </NoticeTextSelectionComponent> + <tr> + <td> + <NoticeTextSelectionComponent idSuffix={this.idSuffix} + text={this.state.messages[i]} + onClick={this.state.messageOnClick} + key={i + "_messageBox"}> + </NoticeTextSelectionComponent> + </td> + </tr> ) } diff --git a/src/content.ts b/src/content.ts index dc7a3427..6320249a 100644 --- a/src/content.ts +++ b/src/content.ts @@ -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)(); } } diff --git a/src/js-components/chat.ts b/src/js-components/chat.ts index ee3e800d..513d8fe4 100644 --- a/src/js-components/chat.ts +++ b/src/js-components/chat.ts @@ -26,8 +26,6 @@ export function openChat(config: ChatConfig): void { }); chat.appendChild(closeButton); - console.log(utils.objectToURI("", config, false)) - const referenceNode = utils.findReferenceNode(); referenceNode.prepend(chat); } |