Greasy Fork is available in English.

Auto Login for Stars

try to take over the world!

À partir de 2016-08-15. Voir la dernière version.

// ==UserScript==
// @name         Auto Login for Stars
// @namespace    http://tampermonkey.net/
// @version      1.0.5
// @description  try to take over the world!
// @author       Kenan
// @include      https://stars.bilkent.edu.tr/*
// @grant        none
// ==/UserScript==

var yourEmailAddress;
var yourPassword;

var stringElements = "start";
var passwordElement;
var passwordID;
var buttons;
var button;

function main() {
    'use strict';
    
    var LS = {
        get : function( id ) {
            var item = localStorage.getItem( id );
            if(item){
                return item.charAt(0)=='{' ? JSON.parse(item) : item;
            }else{
                return {}; 
            }
        },	
        set : function( id, key ) {
            var k = typeof key=="object" ? JSON.stringify( key ) : key;
            console.log( k );
            return localStorage.setItem( id, k );
        },
        del : function( id ){
            return localStorage.removeItem( id );
        }
    };
    
     
    var oU = LS.get('oUser'); // should be a stored Obj
    
    var isMailBox = (window.location.href.includes("https://stars.bilkent.edu.tr/srs/") );
    var wasMailBox = (document.referrer.includes("https://stars.bilkent.edu.tr/srs/"));
    
    if(isMailBox){
        oU.success = true;
    }
    
    if((!oU.name && !isMailBox && !wasMailBox) || (!oU.success)){
        oU.name = prompt("Enter your Stars ID: ");
        oU.password = prompt("Enter your password: ");
        oU.success = false;
        oU.date = new Date().toUTCString();
        
        // Chrome 1+
        /*var isChrome = !!window.chrome && !!window.chrome.webstore;
        if(isChrome)
        {
            location.reload();
        }*/
        
    }else{
        //alert ("Hi " + oU.name + " Welcome back!" + " Date: " + oU.date);
        console.log("elseeeeee");
    }
    //read
    yourEmailAddress = oU.name;
    yourPassword = oU.password;
    //write
    
    LS.set('oUser', oU); // Store back the whole object

    
    
    
    
    if ( !wasMailBox && yourPassword && yourEmailAddress)
    {
        
        $( "#LoginForm_username" ).val( yourEmailAddress );
        passwordElement = document.getElementById("LoginForm_password");
        //passwordElement.type = "visible"; 
        passwordElement.value = yourPassword;

        buttons = document.getElementsByClassName("btn btn-bilkent");
        //buttons = document.getElementsByName("yt0");
        button = buttons[0];
        stringElements += button.name;

        button.click();
    }

}
// Start on load
document.addEventListener('DOMContentLoaded', main() );