Last active
September 13, 2022 03:01
-
-
Save ibnumalik/f23f9bccc3245e96e162cd373872b05f to your computer and use it in GitHub Desktop.
get all services supported in alldebrid
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
const [hosts, streams] = document.querySelectorAll('.downloaders_list'); | |
/** | |
* Get list of services in alldebrid platform. | |
* | |
* @param {NodeListOf<Element>} services Use either `hosts` or `streams` | |
* @returns Object { downloaders_available?: string[]; downloaders_unavailable?: string[] } | |
*/ | |
function getServiceList(services) { | |
let group = {}; | |
[...services.children].forEach(service => { | |
if (!service.firstChild) { | |
return; | |
} | |
const title = service.querySelector('i').getAttribute('title'); | |
if (!group[service.className]) { | |
group[service.className] = [title]; | |
return; | |
} | |
group[service.className] = [...group[service.className], title] | |
}); | |
return group; | |
} | |
/** | |
* Get sorted list of services from alldebrid | |
* | |
* @param {NodeListOf<Element>} services Use either `hosts` or `streams` | |
* @param {string} key Use `downloaders_available` or `downloaders_unavailable` | |
* @returns | |
*/ | |
function showSortedServices(services, key) { | |
return getServiceList(services)[key].sort().forEach(service => console.log(service)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment