PGportal allow password paste and reveal OTP

Install latest with possible future updates OR Install fixed script with no updates

// ==UserScript==
// @name         PGportal allow password paste and reveal OTP
// @version      0.1
// @description  Allow pasting password and reveal OTP in CPGrams PGportal.gov.in
// @author       https://github.com/z-aki
// @namespace    https://github.com/z-aki
// @match        https://pgportal.gov.in/Signin
// @icon         https://pgportal.gov.in/Images/favicon.ico
// @grant        none
// @require      https://gist.githubusercontent.com/adamhotep/7c9068f2196326ab79145ae308b68f9e/raw/373f5e8405b98781001aea9a9e74585367344960/waitForKeyElements.js

Warning

Malicious scripts can violate your privacy and act on your behalf! You should only install scripts from sources that you trust. All scripts in this repo are provided in two versions: updates and no updates controlled by the @downloadURL tag in the script header.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

The trademarks and logos are property of their respective owners (mostly available in the @match directive or @icon directive (except when it's loaded from DuckDuckGo)) and no affiliation, association or endorsement is intended, implied or given by the author.

// ==UserScript==
// @name         PGportal allow password paste and reveal OTP
// @version      0.1
// @description  Allow pasting password and reveal OTP in CPGrams PGportal.gov.in
// @author       https://github.com/z-aki
// @namespace    https://github.com/z-aki
// @match        https://pgportal.gov.in/Signin
// @icon         https://pgportal.gov.in/Images/favicon.ico
// @grant        none
// @require      https://gist.githubusercontent.com/adamhotep/7c9068f2196326ab79145ae308b68f9e/raw/373f5e8405b98781001aea9a9e74585367344960/waitForKeyElements.js
// @downloadURL  none
// ==/UserScript==

function fix(elem) {
  elem.onkeydown = null;
  $("input:password").off("paste");
}

waitForKeyElements("input#TempPassword", fix, false);

function revealPassword(elem) {
  console.log("blahfoo");
  const input = elem.querySelector("#TempPassword");
  const toggleSpan = elem.querySelector(".input-group-addon");

  // Replace the existing span with a toggle eye icon
  toggleSpan.innerHTML = '<i id="showEye" class="fa fa-eye-slash"></i>';

  // Add toggle functionality
  toggleSpan.addEventListener("click", function () {
    // Toggle the input type between 'text' and 'password'
    input.type = input.type === "password" ? "text" : "password";

    toggleSpan.classList.add("toggleEffects");
    setTimeout(() => {
      toggleSpan.classList.remove("toggleEffects");
    }, 300);

    // Toggle the icon class
    const icon = toggleSpan.querySelector("i");
    icon.classList.toggle("fa-eye");
    icon.classList.toggle("fa-eye-slash");
  });
}

waitForKeyElements(
  "div.loginInput:has(input#TempPassword)",
  revealPassword,
  false
);