NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name Appadmin Google Groups helper // @description Replies to customers should use the group "from" address. Warn me if it's a different address. // @namespace https://openuserjs.org/users/floodmeadows // @author floodmeadows // @copyright 2021, floodmeadows (https://openuserjs.org/users/floodmeadows) // @license MIT // @version 1.0.0 // @include https://groups.google.com/a/digital.hmrc.gov.uk/g/appadmin/c/* // @icon https://www.google.com/s2/favicons?domain=google.com // @downloadURL https://openuserjs.org/install/floodmeadows/Appadmin_Google_Groups_helper.user.js // @updateURL https://openuserjs.org/meta/floodmeadows/Appadmin_Google_Groups_helper.meta.js // @grant none // ==/UserScript== (function() { 'use strict'; const fromAddressButtonDelay = 700; const replyButtonDelay = 1200; const fromAddressClassName = "RdyDwe snByac"; const replyButtonClassName = "NPEfkd RveJvd snByac"; const groupAddress = "appadmin@digital.hmrc.gov.uk"; const alertColour = "#f00"; const okColour = "#fff"; document.documentElement.addEventListener("keyup", checkAfterDelay); document.documentElement.addEventListener("mouseup", checkAfterDelay); function checkAfterDelay() { setTimeout(checkFromAddress, fromAddressButtonDelay); } function checkFromAddress() { var fromAddressContainer = document.getElementsByClassName(fromAddressClassName)[0]; var fromAddress = fromAddressContainer.textContent; var fromAddressButton = fromAddressContainer.parentElement.parentElement; if(fromAddress != groupAddress) { fromAddressButton.style.backgroundColor = alertColour; } else { fromAddressButton.style.backgroundColor = okColour; } } function makeReplyButtonLookDisabled() { var replyButton = document.getElementsByClassName("NPEfkd RveJvd snByac")[1]; replyButton.parentElement.parentElement.style.textDecoration = "line-through"; replyButton.parentElement.parentElement.style.backgroundColor = "#ccc"; replyButton.style.color = "#999"; } // Make the button look disabled as soon as possible ... makeReplyButtonLookDisabled(); // ... and then do it again because something else on the page over-rides the appearance changes after a short delay. setTimeout(makeReplyButtonLookDisabled, replyButtonDelay); })();