nicer logs
This commit is contained in:
@@ -31,7 +31,7 @@ let disruption = "";
|
||||
*/
|
||||
const ensureSettingsProp = (prop, existCallback, noExistCallback) => {
|
||||
settings.get(prop).then(foundKeys => {
|
||||
console.log("storage returned", foundKeys);
|
||||
console.debug("storage returned", foundKeys);
|
||||
return (prop in foundKeys ? existCallback(foundKeys[prop]) : noExistCallback());
|
||||
});
|
||||
}
|
||||
@@ -63,11 +63,16 @@ const bankDetailConfigKeys = ["pymt__iban", "pymt__bic"];
|
||||
*/
|
||||
function processSingleAddedNode(n) {
|
||||
if (currentStage.match(n)) {
|
||||
console.log(currentStage.name, "matched: ", n);
|
||||
console.log(currentStage.name, currentStage.execute(n) ? "executed" : "execution failed");
|
||||
console.info(currentStage.name, "matched: ", n);
|
||||
success = currentStage.execute(n)
|
||||
if (success) {
|
||||
console.info(currentStage.name, "executed successfully");
|
||||
} else {
|
||||
console.error(currentStage.name, "failed");
|
||||
}
|
||||
nextStage();
|
||||
} else {
|
||||
console.log(currentStage.name, "did not match: ", n);
|
||||
console.debug(currentStage.name, "did not match: ", n);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,18 +95,23 @@ function processMutations(mutationList, observer) {
|
||||
currentStage = stages.shift();
|
||||
//TODO sniff action and provide field jumps instead
|
||||
} else {
|
||||
console.log("this Stage is invalid, aborting", currentStage);
|
||||
console.error("this Stage is invalid, aborting", currentStage);
|
||||
}
|
||||
}
|
||||
for (const mutation of mutationList) {
|
||||
if ('expects' in currentStage) {
|
||||
if (currentStage.expects == 'mutation') {
|
||||
if (currentStage.match(mutation)) {
|
||||
console.log(currentStage.name, "matched: ", mutation);
|
||||
console.log(currentStage.name, currentStage.execute(mutation) ? "executed" : "execution failed");
|
||||
console.info(currentStage.name, "matched: ", mutation);
|
||||
success = currentStage.execute(mutation);
|
||||
if (success){
|
||||
console.info(currentStage.name, "executed successfully");
|
||||
} else {
|
||||
console.error(currentStage.name, "failed");
|
||||
}
|
||||
nextStage();
|
||||
} else {
|
||||
console.log(currentStage.name, "did not match: ", mutation);
|
||||
console.debug(currentStage.name, "did not match: ", mutation);
|
||||
}
|
||||
} else if (currentStage.expects == 'node' && mutation.type === "childList") {
|
||||
mutation.addedNodes.forEach(processSingleAddedNode);
|
||||
@@ -112,11 +122,13 @@ function processMutations(mutationList, observer) {
|
||||
if (n.nodeType === Node.ELEMENT_NODE) {
|
||||
processSingleAddedNode(n);
|
||||
} else if (!([Node.COMMENT_NODE, Node.TEXT_NODE].includes(n.nodeType))) {
|
||||
console.log("skipping node", n);
|
||||
// skip comment nodes and text nodes without logging
|
||||
// log all the others
|
||||
console.debug("skipping node", n);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
console.log("err: could not dispatch mutation", mutation);
|
||||
console.error("could not dispatch mutation", mutation);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -127,7 +139,7 @@ function nextStage() {
|
||||
if (stages.length > 0) {
|
||||
currentStage = stages.shift();
|
||||
} else {
|
||||
console.log("no more stages - disconnecting observer");
|
||||
console.info("no more stages - disconnecting observer");
|
||||
observer.disconnect();
|
||||
}
|
||||
}
|
||||
@@ -320,7 +332,7 @@ const focusDepartureInput = {
|
||||
const depInput = $$(node, '.fahrplan__start .fahrplan__haltestelle input');
|
||||
const obs = new IntersectionObserver((entries, intObserver) => {
|
||||
if (!(entries.some(e => e.isIntersecting))) return false;
|
||||
console.log("observer fired:", entries);
|
||||
console.debug("observer fired:", entries);
|
||||
depInput.focus();
|
||||
intObserver.disconnect();
|
||||
}, { threshold: 1 });
|
||||
@@ -414,7 +426,7 @@ const enterTextPersonalData = {
|
||||
let node = document;
|
||||
let delay = 100;
|
||||
settings.get(personalDataConfigKeys).then(foundKeys => {
|
||||
console.log("storage returned", foundKeys);
|
||||
console.debug("storage returned", foundKeys);
|
||||
const configKey_Selector = {
|
||||
"addr__firstName": ".test-name-vorname input",
|
||||
"addr__surName": ".test-name-nachname input",
|
||||
@@ -426,13 +438,13 @@ const enterTextPersonalData = {
|
||||
for (const [k, v] of Object.entries(foundKeys)) {
|
||||
if (k in configKey_Selector) {
|
||||
//TODO WIP this only works on some fields
|
||||
console.log("filling", configKey_Selector[k], "with", v);
|
||||
console.debug("filling", configKey_Selector[k], "with", v);
|
||||
setTimeout(() => {
|
||||
fillTextInput(node, configKey_Selector[k], v)
|
||||
}, delay);
|
||||
delay += 100;
|
||||
} else {
|
||||
console.log("no selector found for config key", k);
|
||||
console.warn("no selector found for config key", k);
|
||||
}
|
||||
}
|
||||
setTimeout(() => {
|
||||
@@ -466,7 +478,7 @@ const enterPaymentDetails = {
|
||||
const xfrRadio = node.querySelector('#ueberweisung');
|
||||
xfrRadio.dispatchEvent(new Event('change'));
|
||||
settings.get(bankDetailConfigKeys).then(results => {
|
||||
console.log(results);
|
||||
console.debug(results);
|
||||
for (const [k, v] of Object.entries(results)) {
|
||||
switch (k) {
|
||||
case "pymt__iban":
|
||||
|
Reference in New Issue
Block a user