Initial commit

This commit is contained in:
Balazs Toldi 2021-04-11 17:15:30 +02:00
commit 86699f1698
Signed by: Bazsalanszky
GPG key ID: 933820884952BE27
10 changed files with 161 additions and 0 deletions

3
.gitignore vendored Normal file
View file

@ -0,0 +1,3 @@
*~
\#*\#
web-ext-artifacts

15
bme.js Normal file
View file

@ -0,0 +1,15 @@
var storageItem = browser.storage.local.get('username');
storageItem.then((res) => {
if(res.username != void(0)){
document.getElementById('login-form_username').value = res.username;
}
});
storageItem = browser.storage.local.get('password');
storageItem.then((res) => {
if(res.password != void(0)){
document.getElementById('login-form_password').value = res.password;
}
});
//TODO: Ennél biztosan van jobb megoldás
setTimeout(() => document.forms[0].submit(),500);

BIN
icons/icon-32.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

47
manifest.json Normal file
View file

@ -0,0 +1,47 @@
{
"manifest_version": 2,
"name": "BME Logginer",
"version": "0.1.0",
"description": "Automaticly logs you in to BME accounts",
"icons": {
"32": "icons/icon-32.png"
},
"permissions": ["storage"],
"browser_action": {
"default_icon": "icons/icon-32.png",
"default_title": "BME Logginer",
"default_popup": "popup/credentials.html"
},
"browser_specific_settings": {
"gecko": {
"id": "bme_logginer@toldi.eu",
"strict_min_version": "57.0a1"
}
},
"content_scripts": [
{
"matches": ["*://login.bme.hu/idp/Authn/UserPassword"],
"js": ["bme.js"]
},
{
"matches": ["*://login.microsoftonline.com/common/oauth2/authorize*"],
"js": ["ms.js"]
},
{
"matches": ["*://login.microsoftonline.com/login.srf*"],
"js": ["ms_staysignedin.js"]
},
{
"matches": ["*://edu.vik.bme.hu/","*://online.vik.bme.hu/"],
"js": ["moodle-vik.js"]
},
{
"matches": ["*://edu.gtk.bme.hu/","*://edu.gpk.bme.hu/","*://edu.epito.bme.hu/","*://edu.epitesz.bme.hu/","*://edu.ttk.bme.hu/"],
"js": ["moodle.js"]
}
]
}

1
moodle-vik.js Normal file
View file

@ -0,0 +1 @@
document.getElementsByClassName("btn btn-primary btn-block")[0].click();

1
moodle.js Normal file
View file

@ -0,0 +1 @@
document.getElementsByClassName("login-button")[0].click();

20
ms.js Normal file
View file

@ -0,0 +1,20 @@
setTimeout(() => { var otherAccount = document.getElementById("otherTileText");
if(otherAccount){
otherAccount.click();
}
},400);
setTimeout(() => {
var storageItem = browser.storage.local.get('msemail');
storageItem.then((res) => {
if(res.msemail != void(0)){
document.getElementById('i0116').value = res.msemail;
// document.getElementById('idSIButton9').click()
setTimeout(() => document.getElementById('idSIButton9').click(),2000);
}
});
},1000);
//TODO: Ennél biztosan van jobb megoldás

1
ms_staysignedin.js Normal file
View file

@ -0,0 +1 @@
setTimeout(() => document.getElementById('idBtn_Back').click(),1000);

22
popup/credentials.html Normal file
View file

@ -0,0 +1,22 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="credentials.css"/>
</head>
<body onload="loadCreds()">
<h4>BME Logginer</h4>
<form action="" name="credentials">
<input type="text" id="user" placeholder="Felhasználónév" \><br>
<input type="password" id="passwd" placeholder="Jelszó"\><br>
<span><input type="checkbox" id="isMS"/> Microsoft bejelentkezés<br></span>
<input type="email" id="msemail" placeholder="Microsoft email cím" style="display: none"\><br>
<input type="submit" value="Mentés">
</form>
<p>Figyelem: A megjegyzési adatok csak lokálisan tárolódnak</p>
<script src="credentials.js"></script>
</body>
</html>

51
popup/credentials.js Normal file
View file

@ -0,0 +1,51 @@
function save(e) {
console.log("OK");
browser.storage.local.set({
username: document.querySelector("#user").value
});
browser.storage.local.set({
password: document.querySelector("#passwd").value
});
if(document.querySelector("#isMS").checked){
browser.storage.local.set({
msemail: document.querySelector("#msemail").value
});
}else {
browser.storage.local.set({
msemail: null
});
}
e.preventDefault();
}
function loadCreds() {
var storageItem = browser.storage.local.get('username');
storageItem.then((res) => {
if(res.username != void(0))
document.forms[0].user.value = res.username;
});
storageItem = browser.storage.local.get('password');
storageItem.then((res) => {
if(res.password != void(0))
document.forms[0].passwd.value = res.password;
});
storageItem = browser.storage.local.get('msemail');
storageItem.then((res) => {
if(res.msemail != void(0)){
document.forms[0].msemail.value = res.msemail;
document.forms[0].isMS.checked = true;
document.getElementById("msemail").style.display = "block";
}
});
}
document.addEventListener('DOMContentLoaded', loadCreds);
document.querySelector("form").addEventListener("submit", save);
const checkbox = document.getElementById('isMS')
checkbox.addEventListener('change', (event) => {
document.getElementById("msemail").style.display = event.currentTarget.checked ? 'block' : 'none';
})