-
Notifications
You must be signed in to change notification settings - Fork 0
/
feedback.js
37 lines (33 loc) · 1.27 KB
/
feedback.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
console.log("Running feedback.js");
chrome.storage.sync.get(optionNames, (items) => {
if (items["show_submission_text_length"]) showSubmissionTextLength();
if (items["adjacent_feedback_button"]) duplicateFeedbackButton();
emphasizeLateSubmission();
});
function showSubmissionTextLength() {
const submissionText = document.getElementById("submissionText");
if (submissionText) {
const length = submissionText.textContent.length;
submissionText.insertAdjacentText("afterend", `(${length}文字)`);
}
}
function duplicateFeedbackButton() {
const buttons = document.querySelectorAll(".feedback-transition-btn");
const nextButtons = Array.from(buttons).filter(b => b.textContent.includes("次"));
const errMessage = document.getElementById("errmsg_score");
if (errMessage) {
const target = errMessage.parentElement;
nextButtons.forEach(button => {
const clone = button.cloneNode(true);
target.insertBefore(clone, errMessage);
});
}
}
function emphasizeLateSubmission() {
const spans = document.querySelectorAll("span");
spans.forEach(span => {
if (span.textContent.includes("期限後提出")) {
span.classList.add("strong-warning");
}
});
}