Skip to content

Instantly share code, notes, and snippets.

@Vin-Ren
Last active March 3, 2025 12:13
Show Gist options
  • Select an option

  • Save Vin-Ren/c3407dd0f28a7115b72263c72fea108c to your computer and use it in GitHub Desktop.

Select an option

Save Vin-Ren/c3407dd0f28a7115b72263c72fea108c to your computer and use it in GitHub Desktop.
Autologin to SCELE+EMAS
// ==UserScript==
// @name AutologinSSO
// @namespace http://tampermonkey.net/
// @version 0.0.2
// @author Rendtzy
// @description Plis scele jangan logout2 mulu
// @match https://scele.cs.ui.ac.id/*
// @include https://emas2.ui.ac.id/*
// @grant GM_addElement
// @updateURL https://gist.github.com/Vin-Ren/c3407dd0f28a7115b72263c72fea108c
// ==/UserScript==
// grant fix from https://stackoverflow.com/questions/69786354/tampermonkey-script-blocked-by-a-csp-error
// ####################################################################################################
// ########################################### CONFIG START ###########################################
// KONFIGURASI
const USERNAME = "USERNAME_SSO_DISINI"
const PASSWORD = "PASSWORD_SSO_DISINI"
// ############################################ CONFIG END ############################################
// ####################################################################################################
function sleep(ms) {
var start = new Date().getTime(), expire = start + ms;
while (new Date().getTime() < expire) { }
return;
}
function loginScele() {
const confirmLogoutButton = document.querySelector('div[role="alertdialog"] > * form[method="post"] > button')
if (confirmLogoutButton !== null && confirmLogoutButton.innerHTML==="Log out") {
confirmLogoutButton.click();
return;
}
console.log("Logging you in...")
document.querySelectorAll('input[name="username"]').forEach((el) => {el.value=USERNAME})
document.querySelectorAll('input[type="password"]').forEach((el)=> {el.value=PASSWORD})
document.querySelector('#loginbtn').click()
console.log("Submitting login form...")
}
function redirectToLoginPage() {
console.log("Going to login page...")
const clickToLogin = document.querySelector('.usermenu > span.login > a')
console.log(clickToLogin)
if (clickToLogin !== null) {
clickToLogin.click();
}
}
function routeScele() {
switch (window.location.pathname) {
case '/login/index.php':
loginScele();
break;
default:
console.log("Unsupported path.");
redirectToLoginPage();
}
}
function routeEmas() {
switch (window.location.pathname) {
case '/login/index.php':
loginScele();
break;
default:
console.log("Unsupported path.");
redirectToLoginPage();
}
}
(function() {
console.log("Executing userscript...")
switch (window.location.hostname) {
case 'emas2.ui.ac.id':
routeEmas();
break;
case 'scele.cs.ui.ac.id':
routeScele();
break;
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment