Skip to content

Instantly share code, notes, and snippets.

@helloimbernardo
Last active November 22, 2021 00:01
Show Gist options
  • Save helloimbernardo/e785074ac480316a0d365ca678ba1832 to your computer and use it in GitHub Desktop.
Save helloimbernardo/e785074ac480316a0d365ca678ba1832 to your computer and use it in GitHub Desktop.
MoodleNoDownload
// ==UserScript==
// @name Moodle No Download
// @version 1.0
// @description Open files from moodle directly on your browser without being forced to download them
// @author helloimbernardo (https://github.com/helloimbernardo)
// @homepage https://gist.github.com/helloimbernardo/e785074ac480316a0d365ca678ba1832
// @updateURL https://gist.githubusercontent.com/helloimbernardo/e785074ac480316a0d365ca678ba1832/raw/moodleNoDownload.js
// @downloadURL https://gist.githubusercontent.com/helloimbernardo/e785074ac480316a0d365ca678ba1832/raw/moodleNoDownload.js
// @icon https://www.google.com/s2/favicons?domain=moodle.org
// @icon64 https://www.google.com/s2/favicons?sz=64&domain=moodle.org
// @grant none
// Change this URL to your moodle URL if you are having issues
// @include https://moodle*
// @include http://moodle*
// ==/UserScript==
(function() {
'use strict';
let links = document.getElementsByTagName('a');
for (var i = 0, l = links.length; i < l; i++) {
let current;
current = links[i].href;
if (current.includes('\?forcedownload=1')) {
current = current.replace('?forcedownload=1', '?forcedownload=0');
console.log(current);
links[i].href = current;
}
}
})();
@helloimbernardo
Copy link
Author

helloimbernardo commented Nov 21, 2021

MoodleNoDownload

How to use

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment