PKU auto login

Automatically log in to IAAA, portal and course.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

You will need to install an extension such as Tampermonkey to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name         PKU auto login
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Automatically log in to IAAA, portal and course.
// @author       You
// @match        https://portal.pku.edu.cn/portal2017/
// @match        https://iaaa.pku.edu.cn/*
// @match        https://course.pku.edu.cn/
// @icon         https://www.google.com/s2/favicons?sz=64&domain=pku.edu.cn
// @require      https://code.jquery.com/jquery-3.6.0.min.js
// @grant        none
// @license      MIT
// ==/UserScript==
/* globals jQuery, $, waitForKeyElements */


(function() {
    'use strict';

    if(document.domain == "portal.pku.edu.cn"){
        setTimeout(function(){
            var ele = $("section.mainWrap:nth-child(2) > ul:nth-child(1) > li:nth-child(1) > a:nth-child(1)");
            if(ele && ele[0].href == "https://portal.pku.edu.cn/portal2017/login.jsp"){
                ele[0].click();
            }
        }, 1000);
    }

    if(document.domain == "iaaa.pku.edu.cn"){
        setTimeout(function(){
            $("#logon_button")[0].click();
        }, 500);
    }

    if(document.domain == "course.pku.edu.cn"){
        setTimeout(function(){
            $(".login_stu_a")[0].click();
        }, 500);
    }

})();