Skip to content

Instantly share code, notes, and snippets.

@larryzhao
Last active August 29, 2015 14:07
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save larryzhao/1260e1f22abb57a51574 to your computer and use it in GitHub Desktop.
Save larryzhao/1260e1f22abb57a51574 to your computer and use it in GitHub Desktop.
function batchImport(season, type) {
var script = "// Starting point \n $('.icon-btn-download').trigger('click'); \n\n";
var resourceType = type.toUpperCase();
var url
var timeout = 500;
console.log($(".resource-item[data-format=" + resourceType + "][data-season=" + season + "]").length);
$(".resource-item[data-format=" + resourceType + "][data-season=" + season + "]").each(function(index, element){
var $resourceItem = $(element);
var resourceName = $($resourceItem.find('a')[1]).text().trim();
$resourceItem.find('span > a').each(function(index, element){
$anchor = $(element);
url = $anchor.attr('href');
if (url.match(/^ed2k/)){
script += "// Import " + resourceName + '\n';
script += "setTimeout(function() { $('#_disk_id_23').trigger('click'); }, " + timeout + ");\n";
timeout += 1500;
script += "setTimeout(function() { $('#share-offline-link').val('" + url + "'); }, " + timeout + ");\n";
timeout += 1500;
script += "setTimeout(function() { $('#_disk_id_27').trigger('click'); }, " + timeout + ");\n";
script += "\n";
timeout += 7000;
return false;
}
});
});
console.log(script);
}
batchImport(1, "mp4");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment