Last active
August 29, 2015 14:22
-
-
Save paretje/a4186175756f72e8e5e0 to your computer and use it in GitHub Desktop.
Force HTTPS, in combination with HTTPS Everywhere, on UGent Minerva
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
// ==UserScript== | |
// @name HTTPS Minerva | |
// @version 0.1.3 | |
// @namespace http://www.online-urbanus.be | |
// @downloadURL https://gist.github.com/paretje/a4186175756f72e8e5e0/raw/https-minerva.user.js | |
// @updateURL https://gist.github.com/paretje/a4186175756f72e8e5e0/raw/https-minerva.user.js | |
// @include https://minerva.ugent.be/* | |
// @grant none | |
// ==/UserScript== | |
jQuery.each( [ "get", "post" ], function( i, method ) { | |
jQuery[ method ] = function( url, data, callback, type ) { | |
// shift arguments if data argument was omitted | |
if ( jQuery.isFunction( data ) ) { | |
type = type || callback; | |
callback = data; | |
data = undefined; | |
} | |
if (url.substr(0, 23) == "http://minerva.ugent.be") { | |
url = "https" + url.substr(4); | |
} | |
return jQuery.ajax({ | |
url: url, | |
type: method, | |
dataType: type, | |
data: data, | |
success: callback | |
}); | |
}; | |
}); | |
$("img").each(function() { | |
url = $(this).attr('src'); | |
if (url && url.substr(0, 23) == "http://minerva.ugent.be") { | |
$(this).attr('src', "https" + url.substr(4)); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment