Commit 7818c8ce authored by Vildravn's avatar Vildravn
Browse files

Try to lower memory usage

parent 1040af1d
......@@ -60,6 +60,7 @@ const textStyles = {
// -----------------------------
const cheerio = importModule('cheerio');
let $ = undefined;
if (config.runsInWidget) {
const size = config.widgetFamily;
......@@ -87,13 +88,19 @@ async function createWidget(size) {
const widget = new ListWidget();
widget.setPadding(15, 15, 15, 15);
const whData = await fetchData("https://www.wowhead.com", "loadString");
const $ = cheerio.load(whData);
let whData = await fetchData("https://www.wowhead.com", "loadString");
$ = cheerio.load(whData);
const callings = await parseTextGroup(`#${REGION}-group-calling-quests`, `.tiw-region[data-region="${REGION}"]`);
const torghast = await parseTextGroup(`#${REGION}-group-torghast-wings`, `.tiw-region[data-region="${REGION}"]`);
const affixes = await parseImageGroup(`#${REGION}-group-mythicaffix`, `.tiw-region[data-region="${REGION}"]`);
const worldBoss = await parseTextGroup(`#${REGION}-group-epiceliteworldsl`, `.tiw-region[data-region="${REGION}"]`);
whData = undefined;
$ = undefined;
delete(whData);
delete($);
const callings = await parseTextGroup($, `#${REGION}-group-calling-quests`, `.tiw-region[data-region="${REGION}"]`);
const torghast = await parseTextGroup($, `#${REGION}-group-torghast-wings`, `.tiw-region[data-region="${REGION}"]`);
const affixes = await parseImageGroup($, `#${REGION}-group-mythicaffix`, `.tiw-region[data-region="${REGION}"]`);
const worldBoss = await parseTextGroup($, `#${REGION}-group-epiceliteworldsl`, `.tiw-region[data-region="${REGION}"]`);
widget.backgroundColor = colors.bg;
......@@ -200,7 +207,7 @@ function buildImageItem(parent, image, item) {
}
}
async function parseImageGroup($, widgetSelector, context, side = "both") {
async function parseImageGroup(widgetSelector, context, side = "both") {
var returnData = [];
const widget = $(widgetSelector, context)[0];
......@@ -229,7 +236,7 @@ async function parseImageGroup($, widgetSelector, context, side = "both") {
return returnData;
}
async function parseTextGroup($, widgetSelector, context, side = "both") {
async function parseTextGroup(widgetSelector, context, side = "both") {
var returnData = [];
const widget = $(widgetSelector, context)[0];
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment