Lovi / nPrev NAS Downloader

// ==UserScript==
// @name           nPrev NAS Downloader
// @description    nCore NAS Downloader
// @author         Lovi
// @include        https://ncore.cc/torrents.php?action=details&id=*
// @include        http://192.168.0.18:9091/transmission/web/*
// @version        1.0
// @require	   //ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js
// ==/UserScript==

$(document).ready(function(){
    if ($("#transmission_body").length === 0) {
    	try {
    		var url    = escape($(".download a").attr("href"));
    		var name   = escape($("div.torrent_reszletek_cim").text());
    		var cookie = escape(document.cookie);

    		$(".download").append('<a id="nas_download" href="javascript:null;" style="margin-left: 20px;">LETÖLTÉS NAS-RA</a>');
    		$(".download").append('<input id="nas_download_url" value="http://sware.hu/ncore_nas_downloader.php?url=' + url + '&name=' + name + '&cookie=' + cookie + '" style="position: absolute; margin-left: 50px; opacity: 0.001; cursor: default;" />');
    		$("#nas_download").on("click", function(){
    			document.getElementById("nas_download_url").select();
    			document.execCommand('copy');
    			window.open("http://192.168.0.18:9091/transmission/web/");
    		});
    	}
    	catch (e) {
    		console.log(e.message);
    	}
    }
    else {
    	try {
    		$("#upload_container").show();
    		$("#torrent_upload_url").focus();
		setInterval(function(){
			$("#torrent_path").val("/i-data/md0/video/");
		}, 250);
    	}
    	catch (e) {
    		console.log(e.message);
    	}
    }
});