initial commit
This commit is contained in:
commit
bdcbd3d3aa
5 changed files with 222 additions and 0 deletions
1
.envrc
Normal file
1
.envrc
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
use flake
|
||||||
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
.direnv
|
||||||
127
autologin_at_ed.js
Normal file
127
autologin_at_ed.js
Normal file
|
|
@ -0,0 +1,127 @@
|
||||||
|
// ==UserScript==
|
||||||
|
// @name AutoLogin@Ed
|
||||||
|
// @namespace https://git.js0ny.net/
|
||||||
|
// @version 0.2
|
||||||
|
// @description Auto Login on University of Edinburgh websites
|
||||||
|
// @author js0ny
|
||||||
|
// @match *://edadfed.ed.ac.uk/*
|
||||||
|
// @match *://login.microsoftonline.com/login.srf*
|
||||||
|
// @match *://www.ease.ed.ac.uk/*
|
||||||
|
// @match *://www.myed.ed.ac.uk/*
|
||||||
|
// @match *://www.learn.ed.ac.uk/*
|
||||||
|
// @match *://www.ed.ac.uk/*
|
||||||
|
// @match *://www.wiki.ed.ac.uk/*
|
||||||
|
// @icon https://www.google.com/s2/favicons?sz=64&domain=ed.ac.uk
|
||||||
|
// @grant none
|
||||||
|
// @noframes
|
||||||
|
// ==/UserScript==
|
||||||
|
// Forked from: Jiaxun Yang's original script
|
||||||
|
|
||||||
|
// FILL YOUR CREDENTIALS HERE
|
||||||
|
var uun = "";
|
||||||
|
var password = "";
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
|
||||||
|
if (uun == "" || password == "") {
|
||||||
|
alert("Please fill your credentials")
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// OAuth Redirection
|
||||||
|
if (location.hostname === "edadfed.ed.ac.uk") {
|
||||||
|
// alert("Debug");
|
||||||
|
document.getElementById("userNameInput").value = uun + "@ed.ac.uk";
|
||||||
|
document.getElementById("passwordInput").value = password;
|
||||||
|
document.getElementById("submitButton").click();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// OAuth Microsoft Page
|
||||||
|
if (location.href.startsWith("https://login.microsoftonline.com/login.srf")) {
|
||||||
|
(function() {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const DELAY_MS = 3000;
|
||||||
|
|
||||||
|
setTimeout(function() {
|
||||||
|
const titleElement = document.getElementById('appConfirmTitle');
|
||||||
|
if (titleElement.textContent.includes("Do you trust ed.ac.uk?")) {
|
||||||
|
document.getElementById("idSIButton9").click();
|
||||||
|
}
|
||||||
|
}, DELAY_MS);
|
||||||
|
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
|
||||||
|
// For ease login page
|
||||||
|
if (location.hostname === "www.ease.ed.ac.uk") {
|
||||||
|
|
||||||
|
|
||||||
|
// Input UUN
|
||||||
|
if (location.pathname === "/cosign.cgi") {
|
||||||
|
document.getElementById("login").value = uun;
|
||||||
|
document.getElementById("submit").click();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Input password
|
||||||
|
if (location.pathname === "/login/") {
|
||||||
|
document.getElementById("password").value = password;
|
||||||
|
document.getElementById("submit").click();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (location.hostname === "www.myed.ed.ac.uk") {
|
||||||
|
// MyEd use React to generate this element, so we must use observer
|
||||||
|
function waitForElm(elmId) {
|
||||||
|
return new Promise(resolve => {
|
||||||
|
if (document.getElementById(elmId)) {
|
||||||
|
return resolve(document.getElementById(elmId));
|
||||||
|
}
|
||||||
|
|
||||||
|
const observer = new MutationObserver(mutations => {
|
||||||
|
if (document.getElementById(elmId)) {
|
||||||
|
resolve(document.getElementById(elmId));
|
||||||
|
observer.disconnect();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
observer.observe(document.body, {
|
||||||
|
childList: true,
|
||||||
|
subtree: true
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
waitForElm('login-btn').then((btn) => {
|
||||||
|
btn.click();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (location.hostname === "www.learn.ed.ac.uk") {
|
||||||
|
// Hanlde Login button on homepage
|
||||||
|
const div = document.getElementsByClassName('easelogin-bt');
|
||||||
|
if (div) {
|
||||||
|
div.item(0).click();
|
||||||
|
}
|
||||||
|
// Handle login button on login page
|
||||||
|
const div1 = document.getElementById('ease');
|
||||||
|
if (div1) {
|
||||||
|
div1.getElementsByTagName('a')[0].click();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (location.hostname === "www.ed.ac.uk") {
|
||||||
|
const loginLinkElm = document.getElementsByClassName('footer-login-link');
|
||||||
|
if (loginLinkElm) {
|
||||||
|
loginLinkElm.item(0).href.click()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (location.hostname === "www.wiki.ed.ac.uk") {
|
||||||
|
const loginLinkElm = document.getElementById('login-link');
|
||||||
|
if (loginLinkElm) {
|
||||||
|
loginLinkElm.click()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})();
|
||||||
61
flake.lock
generated
Normal file
61
flake.lock
generated
Normal file
|
|
@ -0,0 +1,61 @@
|
||||||
|
{
|
||||||
|
"nodes": {
|
||||||
|
"flake-utils": {
|
||||||
|
"inputs": {
|
||||||
|
"systems": "systems"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1731533236,
|
||||||
|
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1763283776,
|
||||||
|
"narHash": "sha256-Y7TDFPK4GlqrKrivOcsHG8xSGqQx3A6c+i7novT85Uk=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "50a96edd8d0db6cc8db57dab6bb6d6ee1f3dc49a",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "NixOS",
|
||||||
|
"ref": "nixos-unstable",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": {
|
||||||
|
"inputs": {
|
||||||
|
"flake-utils": "flake-utils",
|
||||||
|
"nixpkgs": "nixpkgs"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"systems": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1681028828,
|
||||||
|
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||||
|
"owner": "nix-systems",
|
||||||
|
"repo": "default",
|
||||||
|
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nix-systems",
|
||||||
|
"repo": "default",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": "root",
|
||||||
|
"version": 7
|
||||||
|
}
|
||||||
32
flake.nix
Normal file
32
flake.nix
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
{
|
||||||
|
description = "template for devShell";
|
||||||
|
|
||||||
|
inputs = {
|
||||||
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||||
|
|
||||||
|
flake-utils.url = "github:numtide/flake-utils";
|
||||||
|
};
|
||||||
|
|
||||||
|
outputs = {
|
||||||
|
self,
|
||||||
|
nixpkgs,
|
||||||
|
flake-utils,
|
||||||
|
}:
|
||||||
|
flake-utils.lib.eachDefaultSystem (
|
||||||
|
system: let
|
||||||
|
pkgs = import nixpkgs {inherit system;};
|
||||||
|
in {
|
||||||
|
# 定义默认的 devShell
|
||||||
|
devShells.default = pkgs.mkShell {
|
||||||
|
packages = with pkgs; [
|
||||||
|
nodejs_24
|
||||||
|
typescript-language-server
|
||||||
|
];
|
||||||
|
|
||||||
|
shellHook = ''
|
||||||
|
node --version
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue