Skip to content

Instantly share code, notes, and snippets.

@anadius
Last active June 16, 2023 12:46
Show Gist options
  • Save anadius/2cd5e0182ea366fa8cb4bb38a7e90789 to your computer and use it in GitHub Desktop.
Save anadius/2cd5e0182ea366fa8cb4bb38a7e90789 to your computer and use it in GitHub Desktop.
srrDB download .sfv for files inside the archive

Drag the bookmarklet to your bookmarks. Open release page on srrDB and click the bookmarklet.
Bookmarklet:

javascript:(()=>{a=b=>b.textContent.trim();d=document;w=window;l=[];for(e of d.querySelectorAll('.box-content-inner>table>tbody>tr')){f=e.children;if(f[0].textContent.trim().replace(/\s+/g,'')!=='Archivedfiles')continue;for(g of f[1].querySelectorAll('tr')){[t,s,c]=g.querySelectorAll('td');if(typeof s==='undefined')break;if(a(s)==='0')continue;l.push(a(t)+' '+a(c));}}l.push('');b=new Blob([l.join('\n')],{type:'octet/stream'});h=d.createElement('a');u=w.URL.createObjectURL(b);h.href=u;h.download=d.querySelector('#release-name').value+'.sfv';d.body.appendChild(h);h.click();w.URL.revokeObjectURL(u);h.remove()})()
trimContent = element => element.textContent.trim();
lines = [];
for (section of document.querySelectorAll('.box-content-inner>table>tbody>tr')) {
columns = section.children;
if (columns[0].textContent.trim().replace(/\s+/g, '') !== 'Archivedfiles') continue;
for (row of columns[1].querySelectorAll('tr')) {
[filename, size, crc] = row.querySelectorAll('td');
if (typeof size === 'undefined') break;
if (trimContent(size) === '0') continue;
lines.push(trimContent(filename) + ' ' + trimContent(crc));
}
}
lines.push('');
blob = new Blob([lines.join('\n')], {
type: 'octet/stream'
});
link = document.createElement('a');
url = window.URL.createObjectURL(blob);
link.href = url;
link.download = document.querySelector('#release-name').value + '.sfv';
document.body.appendChild(link);
link.click();
window.URL.revokeObjectURL(url);
link.remove();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment