Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added icons/folder.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"manifest_version": 3,
"name": "SuperEZ BETA",
"version": "1.3.0.7",
"version": "1.3.1",
"description": "Better online HKU experience with SuperEZ (THIS EXTENSION IS FOR BETA TESTING)",
"background": {
"service_worker": "scripts/background.js"
Expand Down
1 change: 1 addition & 0 deletions scripts/moodle/js/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ function jumpToExamBase() {

const jumpTab = document.createElement("div");
jumpTab.id = "jump-to-exam-base";
jumpTab.style.display = "none";
jumpTab.style.position = "fixed";
jumpTab.style.left = "50vw";
jumpTab.style.top = "30vh";
Expand Down
13 changes: 10 additions & 3 deletions scripts/superload/background.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
// background.js
chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
if (message.action === 'downloadFile') {
// https://moodle.hku.hk/mod/folder/download_folder.php?id=3764675
// https://moodle.hku.hk/mod/folder/view.php?id=3764676
if (message.url.includes('/mod/folder/')) {
message.url = message.url.replace('/view.php?id=', '/download_folder.php?id=');
}
chrome.downloads.download({
url: message.url,
filename: `SuperLoad/${message.address}/${message.filename}.pdf`,
filename: `SuperLoad/${message.address}/${message.filename}.zip`,
saveAs: message.saveAs,
conflictAction: message.conflictAction
}, (downloadId) => {
Expand All @@ -15,10 +20,12 @@ chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
});
} else if (message.action === 'downloadFiles') {
message.downloadFiles.forEach(file => {

if (file.url.includes('/mod/folder/')) {
file.url = file.url.replace('/view.php?id=', '/download_folder.php?id=');
}
chrome.downloads.download({
url: file.url,
filename: `SuperLoad/${file.address}/${file.filename}.pdf`,
filename: `SuperLoad/${file.address}/${file.filename}.zip`,
saveAs: message.saveAs,
conflictAction: message.conflictAction
}, (downloadId) => {
Expand Down
9 changes: 6 additions & 3 deletions scripts/superload/jsx/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ function findPDFLinks() {
let fileLinks = [];
let links = document.getElementsByTagName('a');
// filter links
links = Array.from(links).filter(link => link.href && link.href.includes('https://moodle.hku.hk/mod/resource/') && link.classList.contains('aalink'));
links = Array.from(links).filter(link => link.href && link.href.includes('https://moodle.hku.hk/mod/') && link.classList.contains('aalink'));
for (let link of links) {
if (link.href &&
link.href.includes('https://moodle.hku.hk/mod/resource/')) {
(link.href.includes('https://moodle.hku.hk/mod/resource/')||
link.href.includes('https://moodle.hku.hk/mod/folder/'))){
let fileType = 'unknown';
let iconSrc = '';

Expand All @@ -20,6 +21,8 @@ function findPDFLinks() {
const match = iconSrc.match(/\/f\/([^?]+)/);
if (match && match[1]) {
fileType = match[1].toLowerCase();
} else {
fileType = 'folder';
}
}
}
Expand All @@ -38,7 +41,7 @@ function findPDFLinks() {

window.popup.SuperLoadPopup = async function () {
let fileLinks = findPDFLinks();
let posibleFileTypes = ['pdf', 'file', 'powerpoint', 'spreadsheet', 'archive', 'document', 'video', 'image'];
let posibleFileTypes = ['pdf', 'file', 'powerpoint', 'spreadsheet', 'archive', 'document', 'video', 'image', 'folder'];
let downloadedFileIDs = (await window.utils.getStorageLocal('downloadedFileIDs')).downloadedFileIDs || [];
return (
window.elements.Div({
Expand Down