NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name NameChangeController3 // @license MIT // @version 1 // @grant none // ==/UserScript== var icons = new RegExp(/🔴|🔵|⚪️|✅|🏁|🔵⚪️|✅🔵|✅🔴/); var iconsArr = [ " ","🔵", "⚪️", "🔴", "✅", "🏁", "🔵⚪️", "✅🔵", "✅🔴"]; var selectId = "assignnment-status-select"; /* var iconsObj = { ' ': "Empty", '🔵': "Waiting for feedback", '⚪️': "Can be graded", '🔴': "Reviewed", '✅': "Graded", '🏁': "Graded and processed", '🔵⚪️': "Needs feedback and grade" }; */ function changeName(element, iconArg) { var icon = iconArg || "🔵"; element.value = icon + element.value.replace(icons, ""); } function DeleteIcons(element, iconArg) { var icon = iconArg || "🔵"; element.value = "" + element.value.replace(icons,""); } function getSelect(element) { var selectEl = document.createElement("SELECT"); selectEl.id = selectId; var option = document.createElement("option"); option.text = " Empty"; option.value = " "; //NEEDS_FEEDBACK" selectEl.add(option); option = document.createElement("option"); option.text = "🔵 Waiting for feedback"; option.value = "🔵"; //CAN_BE_GRADED" selectEl.add(option); option = document.createElement("option"); option.text = "⚪️ Can be graded"; option.value = "⚪️"; //CAN_BE_GRADED" selectEl.add(option); option = document.createElement("option"); option.text = "🔴 Reviewed"; option.value = "🔴"; //REVIEWED"; selectEl.add(option); option = document.createElement("option"); option.text = "✅ Graded"; option.value = "✅"; //GRADED"; selectEl.add(option); option = document.createElement("option"); option.text = "🏁 Graded and processed"; option.value = "🏁"; //GRADED_AND_PROCESSED"; selectEl.add(option); option = document.createElement("option"); option.text = "🔵⚪️ Needs feedback and grade"; option.value = "🔵⚪️"; //Feedback and grade"; selectEl.add(option); option = document.createElement("option"); option.text = "✅🔵 Graded but needs feedback"; option.value = "✅🔵"; //Feedback and grade"; selectEl.add(option); option = document.createElement("option"); option.text = "✅🔴 Graded and reviewed"; option.value = "✅🔴"; //Feedback and grade"; selectEl.add(option); var iconMatch = element.value.match(icons); if (iconMatch != null && iconMatch.length > 0) { selectEl.selectedIndex = iconsArr.indexOf(iconMatch[0]); } selectEl.addEventListener('change', (event)=>{ var name = ""; DeleteIcons(element, ""); } ); selectEl.addEventListener('change', (event)=>{ var name = event.target.value; changeName(element, event.target.value); } ); return selectEl; } setTimeout(function() { var element = document.getElementById("content_tag_title"); var span = document.createElement("span"); span.style.marginRight = "8px"; span.innerHTML = "Change status"; var div = document.createElement("div"); div.style.marginTop = "20px"; div.appendChild(span); div.appendChild(getSelect(element)); element.parentNode.appendChild(div); }, 2000);