Skip to content

Instantly share code, notes, and snippets.

@okeeblow
Forked from Nyr/imgur-gif-to-gifv.user.js
Last active August 29, 2015 14:22
Show Gist options
  • Save okeeblow/c5a6d38d244724ab1485 to your computer and use it in GitHub Desktop.
Save okeeblow/c5a6d38d244724ab1485 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name imgur GIFV to GIF
// @description Turn imgur GIFV links into GIF.
// @exclude *imgur.com*
// @version 1.0
// @grant none
// @run-at document-start
// ==/UserScript==
(function () {
var imgur_regex = /^https?:\/\/i\.imgur\.com\/[A-Za-z0-9]+.gifv$/
var result2 = imgur_regex.exec(window.location);
function replace_links() {
var links = document.getElementsByTagName('a');
for (var i = 0; i < links.length; i++) {
var item = links[i];
result2 = imgur_regex.exec(item.href);
if (result2) {
item.href = item.href.slice(0, -1);
}
}
}
window.addEventListener("DOMContentLoaded", replace_links, false);
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment