-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
195 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,52 @@ | ||
const version = chrome.runtime.getManifest().version | ||
const version = chrome.runtime.getManifest().version; | ||
const elmColors = document.getElementsByName("apply_button"); | ||
document.getElementById('version').innerText = `v${version}` | ||
document.getElementById("version").innerText = `v${version}`; | ||
|
||
var USER_INFOR = {}; | ||
// receive mess from background | ||
|
||
function localStorageAction(params) { | ||
if (params.type == "get") { | ||
return localStorage.getItem(params.key); | ||
} | ||
if (params.type == "set") { | ||
localStorage.setItem(params.key, JSON.stringify(params.value)); | ||
} | ||
} | ||
|
||
chrome.runtime.onMessage.addListener(function(message, sender, sendResponse) { | ||
if (message.type === 'popup') { | ||
// Handle the message from the popup script here | ||
console.log('Received message from popup:', message); | ||
|
||
// Send a response back to the popup script | ||
sendResponse({type: 'background', message: USER_INFOR}); | ||
} | ||
}); | ||
chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) { | ||
if (request.type === "background") { | ||
console.log(request.message); | ||
USER_INFOR = request.message; | ||
|
||
//save to local storage | ||
localStorageAction({ type: "set", key: "user_infor", value: USER_INFOR }); | ||
loadLocaltoPopup(); | ||
|
||
} | ||
}); | ||
|
||
function loadLocaltoPopup(){ | ||
if (JSON.parse(localStorage.getItem("user_infor"))) { | ||
USER_INFOR = JSON.parse( | ||
localStorageAction({ | ||
type: "get", | ||
key: "user_infor", | ||
}) | ||
); | ||
|
||
document.getElementById( | ||
"container" | ||
).innerHTML = `<p>Email: ${USER_INFOR.email} </br> | ||
Name: ${USER_INFOR.name} </br> | ||
RollNumber: ${USER_INFOR.rollNumber} </br> | ||
</p>`; | ||
} else { | ||
document.getElementById("container").innerHTML = | ||
'<div>Please Login To <a href="https://fu-edunext.fpt.edu.vn" > EDUNEXT </a></div>'; | ||
} | ||
} | ||
|
||
document.addEventListener("DOMContentLoaded", function () { | ||
loadLocaltoPopup(); | ||
}); |