Last active
August 29, 2015 14:07
-
-
Save larryzhao/1260e1f22abb57a51574 to your computer and use it in GitHub Desktop.
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 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