Skip to content

Instantly share code, notes, and snippets.

@simoneau
Last active August 16, 2016 01:27
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simoneau/6930848ef0a840481270 to your computer and use it in GitHub Desktop.
Save simoneau/6930848ef0a840481270 to your computer and use it in GitHub Desktop.
A user script to rewrite links to imgur.com on https://www.reddit.com to use HTTPS
// ==UserScript==
// @name HTTPS for imgur.com on reddit.com
// @description Rewrite links to use HTTPS for imgur.com on reddit.com.
// @author Matthew Simoneau
// @namespace http://www.matthewsim.com/
// @version 0.1
// @include https://www.reddit.com/*
// ==/UserScript==
var a = document.getElementsByTagName('a');
for (var i = 0; i < a.length; i++) {
var p = /^http:\/\/((:?[im]\.)?imgur\.com\/.*)$/;
var res = p.exec(a[i].href);
if (res != null) {
a[i].href = 'https://' + res[1];
}
}
@simoneau
Copy link
Author

Analytics

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