sis chrome fix

fixes logging in to rpi's SIS on chrome by disabling autocomplete/fill

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         sis chrome fix
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  fixes logging in to rpi's SIS on chrome by disabling autocomplete/fill
// @author       You
// @match        https://sis.rpi.edu/rss/*Login
// @grant        none
// ==/UserScript==

function onDown(e) {
    e.stopImmediatePropagation();
    if (typeof e.target.attributes["data-currentName"] == "undefined") {
        e.target.setAttribute("data-currentName", e.target.attributes.name.value);
        e.target.setAttribute('name','');
    }
    if (typeof e.target.attributes["data-currentID"] == "undefined") {
        e.target.setAttribute("data-currentID", e.target.attributes.id.value);
        e.target.setAttribute('id','');
    }
}

function onUp(e) {
     e.stopImmediatePropagation();
    if (typeof e.target.attributes["data-currentName"] != "undefined") {
        e.target.setAttribute("name", e.target.attributes["data-currentName"].value);
        e.target.removeAttribute("data-currentName");
    }
    if (typeof e.target.attributes["data-currentID"] != "undefined") {
        e.target.setAttribute("id", e.target.attributes["data-currentID"].value);
        e.target.removeAttribute("data-currentID");
    }
}

(function() {
    'use strict';
    var sid = document.getElementById("UserID");
    sid.setAttribute("type", "text");
    sid.addEventListener( "focus", onDown );
    sid.addEventListener( "mousedown", onDown );
    sid.addEventListener( "keydown", onDown );
    sid.addEventListener( "blur", onUp );
    sid.addEventListener( "keyup", onUp );
    
    var pin = document.getElementById("PIN").children[0];
    pin.setAttribute("id", "pin-input");
    pin.addEventListener( "focus", onDown );
    pin.addEventListener( "mousedown", onDown );
    pin.addEventListener( "keydown", onDown );
    pin.addEventListener( "blur", onUp );
    pin.addEventListener( "keyup", onUp );
    
})();