diff --git a/icons/folder.png b/icons/folder.png new file mode 100644 index 0000000..2910c3f Binary files /dev/null and b/icons/folder.png differ diff --git a/manifest.json b/manifest.json index 67a3b5f..f1873cd 100644 --- a/manifest.json +++ b/manifest.json @@ -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" diff --git a/scripts/moodle/js/content.js b/scripts/moodle/js/content.js index dd8e0e2..2d59c85 100644 --- a/scripts/moodle/js/content.js +++ b/scripts/moodle/js/content.js @@ -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"; diff --git a/scripts/superload/background.js b/scripts/superload/background.js index 8bd6216..ebf5e60 100644 --- a/scripts/superload/background.js +++ b/scripts/superload/background.js @@ -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) => { @@ -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) => { diff --git a/scripts/superload/jsx/popup.js b/scripts/superload/jsx/popup.js index ee4f8a6..e5493f1 100644 --- a/scripts/superload/jsx/popup.js +++ b/scripts/superload/jsx/popup.js @@ -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 = ''; @@ -20,6 +21,8 @@ function findPDFLinks() { const match = iconSrc.match(/\/f\/([^?]+)/); if (match && match[1]) { fileType = match[1].toLowerCase(); + } else { + fileType = 'folder'; } } } @@ -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({