Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name v.redd.it replacer
- // @version 0.1
- // @description replaces v.redd.it links with the fallback url so it becomes a direct link
- // @author Xpopy
- // @require http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js
- // @match https://www.reddit.com/
- // @match https://www.reddit.com/r/*
- // @grant none
- // @run-at document-end
- // ==/UserScript==
- this.$ = this.jQuery = jQuery.noConflict(true);
- (function() {
- 'use strict';
- //If you want to automatically remove the player, change the below line from "false" to "true"
- var block_player = false;
- $('.title[data-href-url^="https://v.redd.it"]').each(function() {
- var link = this;
- var outbound_url = $(this).attr('data-outbound-url');
- var postID = outbound_url.split('?', 1)[0].split('_', 2)[1];
- var parentPost = link.closest(".thing.link");
- var subreddit = $(parentPost).attr('data-subreddit');
- var url = "https://www.reddit.com/r/" + subreddit + "/comments/" + postID + "/.json";
- if(block_player){
- $(parentPost).find('.expando-button').click();
- }
- $.getJSON( url, function(data) {
- var newLink = data[0].data.children[0].data.media.reddit_video.fallback_url;
- console.log(link);
- link.setAttribute('href', newLink);
- link.setAttribute('data-outbound-url', newLink);
- link.setAttribute('data-href-url', newLink);
- parentPost.setAttribute('data-url', newLink);
- });
- });
- })();
Add Comment
Please, Sign In to add comment