Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Reddit - Replace imgur links with filmot
- // @namespace http://userscripts.org/scripts/show/105715
- // @author gavin19
- // @description Replaces imgur links with filmot mirror ones.
- // @match http://*.reddit.com/*
- // @include http://*.reddit.com/*
- // @version 1.12
- // ==/UserScript==
- var replaceImgur = {
- repLinks: function (ele) {
- for (var i = 0, len = ele.length; i < len; i += 1) {
- ele[i].href = ele[i].href.replace('imgur', 'filmot');
- if (ele[i].srcurl) {
- ele[i].srcurl = ele[i].srcurl.replace('imgur', 'filmot');
- }
- }
- },
- init: function() {
- var ele, loc = window.location.href;
- if (loc.match(/\/comments\//i)) {
- ele = document.querySelectorAll('.commentarea:not(.side) .sitetable .md a');
- this.repLinks(ele);
- document.body.addEventListener('DOMNodeInserted', function(event) {
- if ((event.target.tagName == 'DIV') && (/even/ig.test(event.target.getAttribute('class')))) {
- var ele = event.target.querySelectorAll('.md a');
- replaceImgur.repLinks(ele);
- }
- }, false);
- } else {
- ele = document.querySelectorAll('.sitetable .thing a.title');
- this.repLinks(ele);
- document.body.addEventListener('DOMNodeInserted', function(event) {
- if ((event.target.tagName == 'DIV') && (event.target.getAttribute('id') && event.target.getAttribute('id').indexOf('siteTable') != -1)) {
- ele = event.target.querySelectorAll('.thing a');
- replaceImgur.repLinks(ele);
- }
- }, true);
- }
- }
- };
- if (document.body) {
- setTimeout(function() {
- replaceImgur.init();
- }, 3000);
- }
- else {
- window.addEventListener("load", function() {
- replaceImgur.init();
- }, false);
- }
Add Comment
Please, Sign In to add comment