Skip to content

Instantly share code, notes, and snippets.

@ibnumalik
Last active September 13, 2022 03:01
Show Gist options
  • Save ibnumalik/f23f9bccc3245e96e162cd373872b05f to your computer and use it in GitHub Desktop.
Save ibnumalik/f23f9bccc3245e96e162cd373872b05f to your computer and use it in GitHub Desktop.
get all services supported in alldebrid
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