Skip to content

Commit 2c8cc34

Browse files
Revert "Add pre-send check and warning (#247)"
This reverts commit bef541e.
1 parent bef541e commit 2c8cc34

3 files changed

Lines changed: 17 additions & 113 deletions

File tree

i18n/en.yaml

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -161,17 +161,7 @@ FeedbackPage:
161161
ContentPlaceholder: Please provide as much detail as you can.
162162
SendEnabled: Send list of my currently enabled addons (recommended)
163163
SubmitButton: Send
164-
PreSendWarning:
165-
Warning: "Warning:"
166-
Override: If you are really sure to send this feedback, you can press the "Send" button again.
167-
Variations:
168-
NotST:
169-
Heading: We are not the Scratch Team.
170-
Description: Keep in mind that Scratch Addons is not affiliated with the Scratch website or the organizations that maintain it. You are still welcome to give ideas to improve your experience on Scratch with Scratch Addons.
171-
Punishment:
172-
Heading: We can't punish people. We are not the Scratch Team. <br>
173-
Description: "Scratch Addons is not affiliated with the Scratch website or the organizations that maintain it. We have no control of the content and the moderation on the Scratch website. {{ .Tag1Start }}There are many ways that you can report on the Scratch website.{{ .Tag1End }}"
174-
164+
175165
# Strings used for /scratch-messaging-transition
176166
SMTPage:
177167
ScratchMessagingLogoAlt: Scratch Messaging Extension logo

layouts/shortcodes/specifics/feedback-form.html

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,12 @@
1-
{{ $ts := now.UnixMilli }}
2-
31
<script>
42
window.i18nStrings = {
53
statusSending: '{{ T "FeedbackPage.Status.Sending" }}',
64
statusSuccess: '{{ T "FeedbackPage.Status.Success" }}',
75
statusFailed: '{{ T "FeedbackPage.Status.Failed" }}',
86
statusOffline: '{{ T "FeedbackPage.Status.Offline" }}',
97
noAddonsList: '{{ T "FeedbackPage.NoAddonsList" }}',
10-
preSendWarning: {
11-
warning: '{{ T "FeedbackPage.PreSendWarning.Warning" }}',
12-
override: '{{ T "FeedbackPage.PreSendWarning.Override" }}',
13-
variations: {
14-
notST: {
15-
heading: '{{ T "FeedbackPage.PreSendWarning.Variations.NotST.Heading" }}',
16-
description: '{{ T "FeedbackPage.PreSendWarning.Variations.NotST.Description" | htmlEscape }}',
17-
},
18-
punishment: {
19-
heading: '{{ T "FeedbackPage.PreSendWarning.Variations.Punishment.Heading" }}',
20-
description: '{{ T "FeedbackPage.PreSendWarning.Variations.Punishment.Description" ( dict "Tag1Start" (add $ts 1) "Tag1End" (add $ts 2) ) | htmlEscape }}',
21-
}
22-
}
23-
},
24-
submitButton: '{{ T "FeedbackPage.SubmitButton" }}'
8+
submitButton: '{{ T "FeedbackPage.SubmitButton" }}',
259
}
26-
window.i18nTimestamp = Number('{{ $ts }}')
2710
</script>
2811
<script defer src="/assets/js/feedback.js"></script>
2912

static/assets/js/feedback.js

Lines changed: 15 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,3 @@
1-
const variations = {
2-
notST: [
3-
/\bscratch\s*team\b/i,
4-
/\bst\b/,
5-
],
6-
punishment: [
7-
/\bban(ing|ned)?\b/,
8-
/\bunban(ing|ned)?\b/,
9-
/\bkick(ing|ed)?\b/,
10-
/\bpunish(ing|ed|ment)?\b/,
11-
/\b(please|pl[sz])\s*block(ing|ed)?\b/,
12-
/\b(please|pl[sz])\s*mut(ed?|ing)\b/,
13-
/\b(please|pl[sz])\s*unmut(ed?|ing)\b/,
14-
/\bblock(ing|ed)?\s*(please|pl[sz])\b/,
15-
/\bmut(ed?|ing)\s*(please|pl[sz])\b/,
16-
/\bunmut(ed?|ing)\s*(please|pl[sz])\b/,
17-
]
18-
}
19-
201
const i18n = window.i18nStrings
212
let lastFeedbackRequestTime = localStorage.getItem("lastFeedbackRequestTime")
223
let wakeUpTimeout = setTimeout(() => {}, 0)
@@ -26,8 +7,6 @@ const usernameField = form.querySelector('#feedback-username')
267
const contentField = form.querySelector("#feedback-content")
278
const submitButton = form.querySelector("#feedback-submit")
289
const addonsListCheckbox = form.querySelector("#feedback-addons-list")
29-
const statusEl = document.querySelector('#feedback-status')
30-
let hasWarnedContent = false
3110

3211
const version = new URL(location.href).searchParams.get("ext_version") || new URL(location.href).searchParams.get("version")
3312

@@ -42,6 +21,7 @@ if (location.hash.length && /[0-9A-Fa-f]/g.test(location.hash.substring(2))) {
4221
}
4322

4423
const setStatus = (statusText, status) => {
24+
const statusEl = document.querySelector('#feedback-status')
4525
statusEl.textContent = statusText
4626
statusEl.hidden = false
4727
statusEl.classList.remove([...statusEl.classList].filter(className => /alert-/.exec(className))[0])
@@ -100,61 +80,13 @@ const holdSendButton = seconds => {
10080
step()
10181
}
10282

103-
const setPreSendWarning = (heading, description) => {
104-
setStatus("", "warning")
105-
const headingEl = document.createElement('p')
106-
headingEl.textContent = heading
107-
statusEl.appendChild(headingEl)
108-
headingEl.insertAdjacentHTML('afterbegin', `<b>${i18n.preSendWarning.warning}</b> `)
109-
const descriptionEl = document.createElement('p')
110-
descriptionEl.innerHTML = description
111-
statusEl.appendChild(descriptionEl)
112-
const overrideEl = document.createElement('p')
113-
overrideEl.textContent = i18n.preSendWarning.override
114-
overrideEl.classList.add('mb-0')
115-
statusEl.appendChild(overrideEl)
116-
holdSendButton(5)
117-
}
118-
119-
for (const variation in variations) {
120-
const variationObj = i18n.preSendWarning.variations[variation]
121-
for (const key in variationObj) {
122-
variationObj[key] = DOMPurify.sanitize(variationObj[key])
123-
}
124-
}
125-
const punishment = i18n.preSendWarning.variations.punishment
126-
punishment.description = punishment.description.replace(window.i18nTimestamp + 1, '<a href="https://en.scratch-wiki.info/wiki/Report">').replace(window.i18nTimestamp + 2, '</a>')
127-
128-
const preSendCheck = content => {
129-
content = content.toLowerCase()
130-
let warningText = false
131-
for (var variation in variations) {
132-
if (variations[variation].some(el => content.search(el) + 1)) {
133-
warningText = [i18n.preSendWarning.variations[variation].heading, i18n.preSendWarning.variations[variation].description]
134-
break
135-
}
136-
}
137-
if (warningText) {
138-
if (hasWarnedContent && hasWarnedContent === content) {
139-
hasWarnedContent = ""
140-
return true
141-
} else {
142-
hasWarnedContent = content
143-
setPreSendWarning(...warningText)
144-
return false
145-
}
146-
} else {
147-
return true
148-
}
149-
}
150-
// preSendCheck('I hate this guy please ban him')
151-
15283
form.addEventListener("submit", async event => {
15384
event.preventDefault()
15485
setStatus(i18n.statusSending, "primary")
15586

15687
usernameField.readOnly = true
15788
contentField.readOnly = true
89+
submitButton.disabled = true
15890

15991
// document.querySelector("#sending").style.display = "block";
16092

@@ -167,20 +99,19 @@ form.addEventListener("submit", async event => {
16799
enabledAddons: addonsListCheckbox.checked ? enabledAddons : null
168100
}
169101

170-
if (preSendCheck(contentField.value)) {
171-
try {
172-
lastFeedbackRequestTime = Date.now()
173-
localStorage.setItem("lastFeedbackRequestTime", lastFeedbackRequestTime)
174-
const res = await fetch("https://scratchaddons-feedback.glitch.me/send", {
175-
method: "POST",
176-
body: JSON.stringify(body)
177-
})
178-
if (!res.ok) throw "";
179-
holdSendButton(10)
180-
setStatus(i18n.statusSuccess, "success")
181-
} catch(err) {
182-
setStatus(i18n.statusFailed, "danger")
183-
}
102+
try {
103+
lastFeedbackRequestTime = Date.now()
104+
localStorage.setItem("lastFeedbackRequestTime", lastFeedbackRequestTime)
105+
const res = await fetch("https://scratchaddons-feedback.glitch.me/send", {
106+
method: "POST",
107+
body: JSON.stringify(body)
108+
})
109+
if (!res.ok) throw "";
110+
holdSendButton(10)
111+
setStatus(i18n.statusSuccess, "success")
112+
} catch(err) {
113+
setStatus(i18n.statusFailed, "danger")
114+
submitButton.disabled = false
184115
}
185116

186117
usernameField.readOnly = false

0 commit comments

Comments
 (0)