/** * Scrapes summoner spells from a METAsrc page * @param {cheerio} $ - The cheerio object */ scrapeSummonerSpells($) { let summonerSpells = []; $('img[src*="/img/spell"]').slice(0, 2).each(function(index) { const key = $(this).attr('src').slice($(this).attr('src').lastIndexOf('/') + 1, -4); if (Mana.gameClient.summonerSpells[key]) summonerSpells.push(Mana.gameClient.summonerSpells[key]); }); return summonerSpells; }
/** * Scrapes summoner spells from a OP.GG page * @param {cheerio} $ - The cheerio object * @param {string} gameMode - A gamemode, from League Client, such as CLASSIC, ARAM, etc. */ scrapeSummonerSpells($, gameMode) { let summonerSpells = []; $("img[src^='//opgg-static.akamaized.net/images/lol/spell/Summoner']").slice(0, 2).each(function(index) { const summoner = Mana.gameClient.summonerSpells[$(this).attr('src').slice(45, -29)]; if (!summoner) return; if (summoner.gameModes.includes(gameMode)) summonerSpells.push(summoner.id); }); return summonerSpells; }
/** * Scrapes item sets from a OP.GG page * @param {cheerio} $ - The cheerio object * @param {object} champion - A champion object, from Mana.gameClient.champions */ scrapePerks($, champion) { let pages = [{ selectedPerkIds: [] }, { selectedPerkIds: [] }]; $('.perk-page').find('img.perk-page__image.tip').slice(0, 4).each(function(index) { const page = Math.trunc(index / 2); pages[page][index % 2 === 0 ? 'primaryStyleId' : 'subStyleId'] = parseInt($(this).attr('src').slice(-8, -4)); }); $('.perk-page__item--active').find('img').slice(0, 12).each(function(index) { pages[Math.trunc(index / 6)].selectedPerkIds.push(parseInt($(this).attr('src').slice(-8, -4))); }); $('.fragment__summary').find('img').slice(0, 6).each(function(index) { pages[index > 2 ? 1 : 0].selectedPerkIds.push(parseInt($(this).attr('src').slice(-8, -4))); }) return pages; }
/** * Get all the departments. * * @returns {Promise<Department[]>} */ async function getAllDepartments() { const html = await httpService.consultaHorarios(); const $ = cheerio.load(html); return $('#departamento > option') .slice(1) .map((i, el) => { const parsedEl = $(el); return { code: parsedEl.val(), name: parsedEl.text() }; }) .get(); }
/** * Scrapes skill order from a Champion.gg page * @param {cheerio} $ - The cheerio object */ scrapeSkillOrder($) { let skills = $('.skill').slice(1, -1); skills.splice(3, 2); let sums = [{ key: i18n.__('key-Q'), sum: 0 }, { key: i18n.__('key-W'), sum: 0 }, { key: i18n.__('key-E'), sum: 0 }]; let skillorder = {}; skills.each(function(index) { $(this).find('div').children().each(function(i) { if (!$(this).hasClass('selected')) return; sums[index % 3].sum += (18 - i); }); if (index % 3 === 0) { sums = sums.sort((a, b) => b.sum - a.sum); skillorder[index === 0 ? 'mf' : 'hw%'] = `${sums[0].key} => ${sums[1].key} => ${sums[2].key}`; sums[0].sum = sums[1].sum = sums[2].sum = 0; } }); return skillorder; }
itemrows.slice(0, 2).each(function(index) { let starter = new Block().setType({ i18n: 'item-sets-block-starter-skill-order-numbered', arguments: [index + 1, skillorder] }); let pots = 0; const id = $(this).attr('src').slice(44, 48); items[id] = items[id] + 1 || 1; }); itemrows.slice(2, -3).find('li:not(.champion-stats__list__arrow) > img').each(function(index) { recommanded.addItem($(this).attr('src').slice(44, 48), false); }); itemrows.slice(-3).find('img').each(function(index) { boots.addItem($(this).attr('src').slice(44, 48)); });
}); var items = []; $('.olt tr').slice(1).each(function (index, el) { var title = $('.title > a', el).attr('title'); if (checkIncludeWords(title, includeWords) && checkExcludeWords(title, excludeWords)) {
let $ = parser.load(html) let trs = $('.tabproperty table tr').slice(2)
var $tr = $('.tabcontent').eq(2).find('tr').slice(1); $tr.each(function(){ records.push({
/** * Scrapes summoner spells from a OP.GG page * @param {cheerio} $ - The cheerio object * @param {string} gameMode - A gamemode, from League Client, such as CLASSIC, ARAM, etc. */ scrapeSummonerSpells($, gameMode) { let summonerSpells = []; $("img[src^='//opgg-static.akamaized.net/images/lol/spell/Summoner']").slice(0, 2).each(function(index) { const summoner = Mana.gameClient.summonerSpells[$(this).attr('src').slice(45, -29)]; if (!summoner) return; if (summoner.gameModes.includes(gameMode)) summonerSpells.push(summoner.id); }); return summonerSpells; }
/** * Get all the levels. * * @returns {Promise<Level[]>} */ async function getAllLevels() { const html = await httpService.consultaHorarios(); const $ = cheerio.load(html); return $('#nivel > option') .slice(1) .map((i, el) => { const parsedEl = $(el); return { code: parsedEl.val(), name: parsedEl.text() }; }) .get(); }
/** * Get all periods. * * @returns {Promise<Period[]>} */ async function getAllPeriods() { const html = await httpService.consultaHorarios(); const $ = cheerio.load(html); return $('#periodo > option') .slice(1) .map((i, el) => { const parsedEl = $(el); return { code: parsedEl.val(), name: parsedEl.text() }; }) .get(); }
/** * Scrapes item sets from a OP.GG page * @param {cheerio} $ - The cheerio object * @param {object} champion - A champion object, from Mana.gameClient.champions * @param {string} position - Limited to: TOP, JUNGLE, MIDDLE, ADC, SUPPORT */ scrapePerks($, champion, position) { let pages = [{ selectedPerkIds: [] }, { selectedPerkIds: [] }]; $('.perk-page').find('img.perk-page__image.tip').slice(0, 4).each(function(index) { const page = Math.trunc(index / 2); pages[page][index % 2 === 0 ? 'primaryStyleId' : 'subStyleId'] = parseInt($(this).attr('src').slice(-8, -4)); }); $('.perk-page__item--active').find('img').slice(0, 12).each(function(index) { pages[Math.trunc(index / 6)].selectedPerkIds.push(parseInt($(this).attr('src').slice(-8, -4))); }); $('.fragment__summary').find('img').slice(0, 6).each(function(index) { pages[index > 2 ? 1 : 0].selectedPerkIds.push(parseInt($(this).attr('src').slice(-8, -4))); }) return pages; }
}); var items = []; $('.olt tr').slice(1).each(function (index, el) { var title = $('.title > a', el).attr('title'); if (checkIncludeWords(title, includeWords) && checkExcludeWords(title, excludeWords)) {
itemrows.slice(0, 2).each(function(index) { let starter = new Block().setType({ i18n: 'item-sets-block-starter-skill-order-numbered', arguments: [index + 1, skillorder] }); let pots = 0; const id = $(this).attr('src').slice(44, 48); items[id] = items[id] + 1 || 1; }); itemrows.slice(2, -3).find('li:not(.champion-stats__list__arrow) > img').each(function(index) { recommanded.addItem($(this).attr('src').slice(44, 48), false); }); itemrows.slice(-3).find('img').each(function(index) { boots.addItem($(this).attr('src').slice(44, 48)); });