Skip to content

Commit

Permalink
Update version and add redirect script
Browse files Browse the repository at this point in the history
  • Loading branch information
adlsdztony committed Nov 30, 2023
1 parent 1e96690 commit 0b78e2b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
6 changes: 5 additions & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"manifest_version": 3,
"name": "FastHKU",
"version": "2.1",
"version": "2.2",
"description": "One step to access HKU services",
"content_scripts": [
{
Expand All @@ -21,6 +21,10 @@
"matches": ["https://moodle.hku.hk/login/index.php"],
"js": ["scripts/moodle_goto_login.js"],
"run_at": "document_end"
},
{
"matches": ["https://moodle.hku.hk/"],
"js": ["scripts/redirect_to_login.js"]
}
],
"action": {
Expand Down
13 changes: 13 additions & 0 deletions scripts/redirect_to_login.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@


try {
// check if user is logged in
if (document.getElementsByClassName("pull-right")[0].getElementsByTagName("a")[0].innerHTML == "login") {
// user is not logged in
// redirect to login page "https://moodle.hku.hk/login/index.php"
document.location.href = "https://moodle.hku.hk/login/index.php";
}
} catch (error) {
// user is logged in
// do nothing
}

0 comments on commit 0b78e2b

Please sign in to comment.