Help with reg ex / conditions

Filtering a list is something we have been thinking about for some time when the website itself doesn’t offer a way to filter the search result. We don’t have an easy way to do filter lists right now.

We are making progress in this direction using data sources. It is not completely ready yet.

A workaround in the meantime is to use a JavaScript selector. JS can be used to modify the content in any way one needs to and then monitor the modified content. Just like other selectors, JS selectors need to select and return a list of elements. Following are some simple JS examples. In these examples, we use $ as the jQuery object.

  1. tracking changes to urls instead of their text in a page:

$('.table a').each((_, a) => a.textContent = a.href)

  1. Tracking changes to a style attribute of an element:

$('div.special').text( $('div.special').attr('style'))

  1. Formatting content before monitoring it. Note that scripts spanning multiple lines also work. One needs to make sure that the last expression evaluates to an element or a list of elements.
let text = document.body.textContent;
let monitoredText = text.replace('hello', 'hola');
documnet.body.textContent = monitoredText;
document.body;

The main technique for using the JS selector is that it evaluates to a list of elements in the DOM. Before returning the elements, JS can modify them in any way.

In your case, following pseudo code shows a potential solution:

function isGoodDeal(elItem) {
  let price = parseFloat($(elItem).find('.price').text());
  return price < 100;
}

let items = $('.list-items').toArray();
items = items.filter(el => isGoodDeal(el));
items;

Hope this helps. Let me know if you need help creating the script for the URL you are monitoring.

Cheers!