// ==UserScript== // @name Them link download folder ggdrive // @version 0.4.3 // @description none // @author vozer // @match https://drive.google.com/drive/u/* // @match https://drive.google.com/drive/folders/* // @require https://code.jquery.com/jquery-3.3.1.min.js // @grant none // ==/UserScript== let RESET = false; let intervals = []; function parseFileSize(val) { let amplifier; if (/k/i.test(val)) {amplifier = -1} else if (/m/i.test(val)) {amplifier = 0} else if (/g/i.test(val)) {amplifier = 1} else {amplifier = -2} const size = parseInt(val.match(/[0-9.]+/i))*Math.pow(1024, amplifier); return size; } function checkExpired() { let counter = 300; $('.link-list').append(`
Time left: ${counter} s
`); intervals.push(setInterval(() =>{ if (counter > 0 ) { counter--; $('#counter').text(`Time left: ${counter} s. Nhấn chuột phải để xem video trực tiếp.`); } else { $('.link-list').empty(); $('.link-list').append(`
Expired. Please click moè again!
`); } },1000)); } function downAll() { $('.dl-button > a').each(function() { window.open($(this).attr('href')); }) } $('.a-D-B-Lc-j').append('') $('#cat-dl').on('click',() => { console.log('Getting...'); while (intervals.length>0){ clearInterval(intervals[0]); intervals.shift(); } const checkElem = setInterval(() => { if ($('.WYuW0e').length) { clearInterval(checkElem); if ($('.link-list').length) { console.log($('.link-list')) $('.link-list').remove(); $('.vid-player').remove(); } $('.v9czFf').last().before(`
`); $('#downAll').click(() => downAll()); checkExpired(); setTimeout(() => { $('.link-list div').sort(function(a,b) { const contentA = parseInt( $(a).attr('id')); const contentB = parseInt( $(b).attr('id')); return (contentA < contentB) ? -1 : (contentA > contentB) ? 1 : 0; }).appendTo('.link-list'); $('.dl-button').each(function() { $(this).contextmenu(() => { $('.vid-player').html(`
This plays ${$(this).text()}
`); }); }); }, 3000); $('.NtzyH').last().find('.WYuW0e:not(.RDfNAe)').each(function(i) { const fileId = $(this).attr('data-id'); const fileName = $(this).find('.KL4NAf').text() || $(this).find('.Q5txwe').text(); const fileSize = $(this).find('.jApF8d:last').text(); if(!fileSize || parseFileSize(fileSize) >= 100) { $.get(`/uc?id=${fileId}&export=download`, html => { const dlLink = $(html).find('#uc-download-link').attr('href'); $('.link-list').append(`
${fileName} - ${fileSize}
`); }); } else { $('.link-list').append(`
${fileName} - ${fileSize}
`); } }); } }, 100); });