Restock - Check all elements for text to get stock status from, strip any text returned

Re #2039
pull/2040/head
dgtlmoon 11 months ago
parent 792fedb8bc
commit 2ca1b0582f

@ -61,4 +61,4 @@ class perform_site_check(difference_detection_processor):
# Always record the new checksum # Always record the new checksum
update_obj["previous_md5"] = fetched_md5 update_obj["previous_md5"] = fetched_md5
return changed_detected, update_obj, self.fetcher.instock_data.encode('utf-8') return changed_detected, update_obj, self.fetcher.instock_data.encode('utf-8').strip()

@ -61,12 +61,12 @@ function isItemInStock() {
negateOutOfStockRegexs_r.push(new RegExp(negateOutOfStockRegexs[0], 'g')); negateOutOfStockRegexs_r.push(new RegExp(negateOutOfStockRegexs[0], 'g'));
} }
const elementsToScan = Array.from(document.getElementsByTagName('*'));
const elementsWithZeroChildren = Array.from(document.getElementsByTagName('*')).filter(element => element.children.length === 0); //const elementsWithZeroChildren = Array.from(document.getElementsByTagName('*')).filter(element => element.children.length === 0);
// REGEXS THAT REALLY MEAN IT'S IN STOCK // REGEXS THAT REALLY MEAN IT'S IN STOCK
for (let i = elementsWithZeroChildren.length - 1; i >= 0; i--) { for (let i = elementsToScan.length - 1; i >= 0; i--) {
const element = elementsWithZeroChildren[i]; const element = elementsToScan[i];
if (element.offsetWidth > 0 || element.offsetHeight > 0 || element.getClientRects().length > 0) { if (element.offsetWidth > 0 || element.offsetHeight > 0 || element.getClientRects().length > 0) {
var elementText=""; var elementText="";
if (element.tagName.toLowerCase() === "input") { if (element.tagName.toLowerCase() === "input") {
@ -87,8 +87,8 @@ function isItemInStock() {
} }
// OTHER STUFF THAT COULD BE THAT IT'S OUT OF STOCK // OTHER STUFF THAT COULD BE THAT IT'S OUT OF STOCK
for (let i = elementsWithZeroChildren.length - 1; i >= 0; i--) { for (let i = elementsToScan.length - 1; i >= 0; i--) {
const element = elementsWithZeroChildren[i]; const element = elementsToScan[i];
if (element.offsetWidth > 0 || element.offsetHeight > 0 || element.getClientRects().length > 0) { if (element.offsetWidth > 0 || element.offsetHeight > 0 || element.getClientRects().length > 0) {
var elementText=""; var elementText="";
if (element.tagName.toLowerCase() === "input") { if (element.tagName.toLowerCase() === "input") {

Loading…
Cancel
Save