forked from DebaucheryLibrarian/traxxx
Improved q so missing date element returns null.
This commit is contained in:
@@ -7,9 +7,9 @@ function q(context, selector, attrArg, trim = true) {
|
||||
const attr = attrArg === true ? 'textContent' : attrArg;
|
||||
|
||||
if (attr) {
|
||||
const value = context.querySelector(selector)[attr];
|
||||
const value = context.querySelector(selector)?.[attr];
|
||||
|
||||
return trim ? value.trim() : value;
|
||||
return trim ? value?.trim() : value;
|
||||
}
|
||||
|
||||
return context.querySelector(selector);
|
||||
@@ -26,7 +26,9 @@ function qall(context, selector, attrArg, trim = true) {
|
||||
}
|
||||
|
||||
function qdate(context, selector, format, match, attr = 'textContent') {
|
||||
const dateString = context.querySelector(selector)[attr];
|
||||
const dateString = context.querySelector(selector)?.[attr];
|
||||
|
||||
if (!dateString) return null;
|
||||
|
||||
if (match) {
|
||||
const dateStamp = dateString.match(match);
|
||||
|
||||
Reference in New Issue
Block a user