diff --git a/package.json b/package.json index 554d8fb..2b69cc0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "amoqueue-wx", - "version": "10.4.6", + "version": "10.5.0", "author": "Philipp Kewisch ", "homepage": "https://github.com/kewisch/amo-helper#readme", "repository": { diff --git a/src/content/reviewinfo/review.css b/src/content/reviewinfo/review.css index f1c1ff6..cc2b458 100644 --- a/src/content/reviewinfo/review.css +++ b/src/content/reviewinfo/review.css @@ -93,7 +93,14 @@ background-image: linear-gradient(to bottom,transparent 0,transparent 123px,#0c99d5 123px,#0c99d5 200px,#fff 200px,rgba(12,153,213,0) 400px); } -#addon .is_recommendable.amoqueue-vip { +#addon .is_promoted.amoqueue-vip { color: white; background-color: #1E5631; + font-size: 1.2em; +} + +.amoqueue-action-warning { + font-weight: bold; + font-size: 1.2em; + color: red; } diff --git a/src/content/reviewinfo/review.js b/src/content/reviewinfo/review.js index 7362f6f..1441b98 100644 --- a/src/content/reviewinfo/review.js +++ b/src/content/reviewinfo/review.js @@ -25,28 +25,61 @@ async function initLayout() { }); } +function updateTags(tagMap) { + let value = document.querySelector("#id_action .on-tab input").value; + let submit = document.querySelector(".review-actions-save input[type='submit']"); + let message = document.querySelector(".amoqueue-action-warning"); + + if (tagMap["no-action"]) { + message.textContent = "Please don't take action: " + tagMap["no-action"]; + } else { + submit.disabled = true; + if (tagMap["no-reject"] && value.includes("reject")) { + message.textContent = "Please do not reject: " + tagMap["no-reject"]; + } else if (tagMap["no-engage"] && (value.includes("reject") || value == "reply")) { + message.textContent = "Please do not engage: " + tagMap["no-engage"]; + } else { + message.textContent = ""; + submit.disabled = false; + } + } +} + function markVIP() { - let privboard = document.getElementById("id_whiteboard-private"); + let privboard = document.getElementById("id_whiteboard-private").textContent; let hasMozillaAuthor = !!document.querySelector("#scroll_sidebar li a[href$='/firefox/user/4757633/']"); - let match = privboard.textContent.match(/\[vip\]\s*([^\n]*)/); + let tags = privboard.matchAll(/\[([a-zA-Z_-]+)\]\s*([^\n]+)/g) || []; + let tagMap = {}; + for (let [, tag, reason] of tags) { + tagMap[tag] = reason; + } + + if (!tags.vip && hasMozillaAuthor) { + tags.vip = "This is an official Mozilla add-on"; + } - if (match || hasMozillaAuthor) { + if (tagMap.vip) { let history = document.getElementById("versions-history"); let bar = history.parentNode.insertBefore(document.createElement("p"), history.nextElementSibling); - bar.className = "is_recommendable amoqueue-vip"; + bar.className = "is_promoted amoqueue-vip"; let descr = bar.appendChild(document.createElement("div")); descr.textContent = "This is a VIP add-on. Please contact an admin before rejecting or sending an information request."; - if (match && match[1]) { - let reason = bar.appendChild(document.createElement("div")); - reason.textContent = "Details: " + match[1]; - } else if (hasMozillaAuthor) { - let reason = bar.appendChild(document.createElement("div")); - reason.textContent = "Details: This is an official Mozilla extension."; - } + let reasonDetails = bar.appendChild(document.createElement("div")); + reasonDetails.textContent = "Details: " + tagMap.vip; } + + let saveSection = document.querySelector(".review-actions-section.review-actions-save"); + let message = document.createElement("span"); + message.className = "amoqueue-action-warning"; + saveSection.insertBefore(message, saveSection.firstElementChild); + + updateTags(tagMap); + document.getElementById("id_action").addEventListener("click", (event) => { + updateTags(tagMap); + }); } function addBlocklistButton() { diff --git a/src/manifest.json b/src/manifest.json index 39e2b50..7d2c020 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -2,7 +2,7 @@ "manifest_version": 2, "name": "AMO Review Helper", "short_name": "AMO Helper", - "version": "10.4.6", + "version": "10.5.0", "applications": { "gecko": { "id": "@amoqueue",