Last active
February 11, 2024 23:55
-
-
Save sergiolopes/f0d732ed37b52833a808 to your computer and use it in GitHub Desktop.
urls do google drive / scribd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(){ | |
var FOLDERS_A_MAIS = [ | |
// Opcional: URLs extras de folders alem do atual. Exemplo: | |
//'https://drive.google.com/drive/folders/0Bwai0kYN-ieKdlJDVlliT1Z4VzA', | |
]; | |
function processFolder(superString) { | |
var files = JSON.parse(superString)[0]; | |
if (files != null) { | |
return Promise.all( | |
files.map((file) => { | |
var id = file[0]; | |
var type = file[3]; | |
if (type.endsWith('folder')) { | |
return loadFolder('https://drive.google.com/drive/folders/' + id); | |
} else if (/mp4|pdf|zip|rar/.test(type)) { | |
return id; | |
} else { | |
console.log('Ignorei arquivo que não conheço tipo', file[2]); | |
} | |
}) | |
).then(values => [].concat.apply([], values)); | |
} | |
} | |
function loadFolder(uri) { | |
return fetch(uri, { credentials: 'include'}) | |
.then(res => res.text()) | |
.then(txt => { | |
return processFolder( | |
txt | |
.match(/window\[\'_DRIVE_ivd\'\]\s*=\s*\'([^\']+)\'/m)[1] | |
.replace(/\\x22/g,'"') | |
.replace(/\\x5b/g,'[').replace(/\\x5d/g,']') | |
.replace(/\\x7b/g,'{').replace(/\\x7d/g,'}') | |
.replace(/\\n/g,'').replace(/\\\\/g,'\\') | |
); | |
}); | |
} | |
Promise.all([processFolder(window['_DRIVE_ivd'])].concat(FOLDERS_A_MAIS.map((f) => loadFolder(f)))) | |
.then(ids => { | |
return ids.reduce((a,b) => a.concat(b)).filter(id => !!id).map(id => 'https://drive.google.com/file/d/' + id +'/view') | |
.reduce((url,acumulado) => acumulado + '\r\n' + url); | |
}) | |
.then(txt => { | |
var ta = document.createElement('textarea'); | |
document.body.appendChild(ta); | |
ta.value = txt; | |
ta.select(); | |
document.execCommand('copy'); | |
alert('Pronto, as URLs tão no Cmd+V'); | |
}) | |
}()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:void function(){ | |
var txt = [].slice.call(document.querySelectorAll('a.doc_link')).map(el => el.href).reduce((url,acc) => acc + '\r\n' + url); | |
var ta = document.createElement('textarea'); | |
document.body.appendChild(ta); | |
ta.value = txt; | |
ta.select(); | |
document.execCommand('copy'); | |
}(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment