diff --git a/.gitignore b/.gitignore index 1d74e21..7aa1a6e 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,4 @@ .vscode/ + +_metadata/ +.DS_Store \ No newline at end of file diff --git a/manifest.json b/manifest.json index 8d1d3fe..494a300 100644 --- a/manifest.json +++ b/manifest.json @@ -110,13 +110,22 @@ "tabs", "activeTab", "cookies", - "downloads" + "downloads", + "webRequest", + "declarativeNetRequest" ], "host_permissions": [ "https://hkuportal.hku.hk/*", "https://moodle.hku.hk/*", "https://booking.lib.hku.hk/*" ], + "declarative_net_request": { + "rule_resources": [{ + "id": "ruleset_1", + "enabled": true, + "path": "rules/moodle_pdf_download_rules.json" + }] + }, "icons": { "16": "images/icon16.png", "32": "images/icon32.png", diff --git a/rules/moodle_pdf_download_rules.json b/rules/moodle_pdf_download_rules.json new file mode 100644 index 0000000..3f11828 --- /dev/null +++ b/rules/moodle_pdf_download_rules.json @@ -0,0 +1,18 @@ +[{ + "id": 1, + "priority": 1, + "action": { + "type": "redirect", + "redirect": { + "transform": { + "queryTransform": { + "removeParams": ["forcedownload"] + } + } + } + }, + "condition": { + "urlFilter": "https://moodle.hku.hk/pluginfile.php", + "resourceTypes": ["main_frame", "sub_frame", "object", "xmlhttprequest", "stylesheet", "script"] + } +}] \ No newline at end of file