Goodgy / Gyazo Enchanter

// ==UserScript==
// @name        Gyazo Enchanter
// @description This script redirects you to the direct link off a gyazo image
// @copyright   2016, Goodgy.eu
// @author      Goodgy
// @namespace   https://openuserjs.org/users/Goodgy
// @require     http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js
// @include     http://*.gyazo.com/*
// @include     http://*gyazo.com/*
// @include     http*://gyazo.com/*
// @include     http*://*gyazo.com/*
// @version     1.4
// ==/UserScript==

function change_window_url(){

    // check if it's a image or video
    var video = $('source').length
    var result;
    if(video == 1){
        // Set variable result to the full img url
        result = $('video > source').attr('src');
    }else{
        // Set variable result to the full img url
        result = $('img.image-viewer').attr('src');
    }

    if((window.location.href.indexOf("https://gyazo.com/") > -1) || (window.location.href.indexOf("https://www.gyazo.com/") > -1)){
        // Set window location to full img url
        window.location = result;
    }
}

function startup(){
    // Load functions
    setTimeout(change_window_url,500);
    console.log("Finished Startup");
}

window.onload = startup();