// ==UserScript== // @id nima-rahbar // @name Lynda Video Downloader // @name:fa دانلود ویدیوهای سایت لیندا // @version 1.0.1 // @author Nima Rahbar // @namespace https://www.github.com/nima-rahbar // @description Download videos on Lynda.com // @description:fa دانلود ویدیوهای سایت لیندا بعد از ورود // @icon https://nimarahbar.com/wp-content/uploads/2017/07/favicon.png // @license MIT // @match https://www.lynda.com/* // @grant GM_xmlhttpRequest // @require https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js // @require https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.1/js/all.min.js // @downloadURL https://update.greasyfork.icu/scripts/437112/Lynda%20Video%20Downloader.user.js // @updateURL https://update.greasyfork.icu/scripts/437112/Lynda%20Video%20Downloader.meta.js // ==/UserScript== this.$ = this.jQuery = jQuery.noConflict(true); $(document).ready(function(){ if( $('div.col-xs-11.col-md-10.video-name-cont').length != 0 ){ $('head').append(''); $('
', { id: "allvids", style: "width:100%; max-height:300px; margin:20px 0; padding: 10px 15px; background-color:rgba(51,51,51,.8); color: #fff; overflow-y: auto; border-radius: 5px;", html: '

Download Videos

', }).appendTo('#course-feedback'); var defaultTitle = $('.default-title').text(); var videoList = $('div.col-xs-11.col-md-10.video-name-cont'); $('#allvids').append(''); var vidDown = $('#allvids ul'); $(videoList).each(function(v_i, item){ var videoData = $(item).find('a'), videoURL = $(videoData).attr('href'), rawTitle = trim($(item).find('a').html()), forbidden_chars = ['?', ':', '<', '>', '*'], wholeTitle = (v_i + 1) + ' - ' + rawTitle.replace(/^\.{1,}(.+)$/m, '$1'); // Remove first dot (if exists) for(var i = 0; i < forbidden_chars.length; i++){ while(wholeTitle.indexOf(forbidden_chars[i]) != -1){ wholeTitle = wholeTitle.replace(forbidden_chars[i], ""); } } if( v_i < 9 ){ wholeTitle = "0" + wholeTitle; } $(vidDown).append( '
  • ' + wholeTitle + '
  • ' ); }); $('.single-video-download').on('click', function(e){ e.preventDefault(); var $this = $(this), videoURL = $(this).data('url'); if( $this.siblings('a').length == 0 ){ $('
    ',{ id: 'responseVid' }).appendTo( $('body') ).hide(); $.ajax({ url: videoURL, dataType: 'html', beforeSend: function(){ $this.after(''); }, success: function(response) { $('#responseVid').html($(response)); $this.attr('href', $('#responseVid').find('div#courseplayer video.player').data('src')); //window.open( $('#responseVid').find('div#courseplayer video.player').data('src') ); $('#responseVid').remove(); }, complete: function(){ $this.siblings('.fa-spinner').fadeOut(600, function(){ $this.siblings('.fa-spinner').remove(); $this.before(''); $this.siblings('a').hide().fadeIn(1000); }); }, }); } }); function trim(str){ return str.replace(/(^\s*)|(\s*$)/g, ''); } } });