Skip to content

Commit 9108524

Browse files
committed
Tidied RunWhenReady() logging
1 parent 46320c1 commit 9108524

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/main.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,11 @@ function RunWhenReady(selectors, code) {
199199
if(typeof selectors == "string") {
200200
selectors = [selectors];
201201
}
202-
DebugLog("RunWhenReady(): Running on [\"" + selectors.join("\", \"") + "\"], code = ```\n" + code + "\n```");
202+
try {
203+
DebugLog("RunWhenReady(\"" + selectors.join("\", \"") + "\"): Run from " + (new Error).stack.split("\n")[1].split("/")[4]);
204+
} catch(TypeError) {
205+
DebugLog("RunWhenReady(\"" + selectors.join("\", \"") + "\"): Running...");
206+
}
203207

204208
var loadedElement, isLoaded;
205209
function GetLoadedElement(mutationInstance = null) {
@@ -208,7 +212,7 @@ function RunWhenReady(selectors, code) {
208212
loadedElement = document.querySelector(selectors[i])
209213
} catch(TypeError) {}
210214
if(loadedElement != null) {
211-
DebugLog("RunWhenReady(): Element with selector \"" + selectors[i] + "\" loaded...");
215+
DebugLog("RunWhenReady(\"" + selectors.join("\", \"") + "\"): Loaded.");
212216
code(loadedElement);
213217
if(mutationInstance != null) { // Running in observer:
214218
mutationInstance.disconnect();

0 commit comments

Comments
 (0)