Greasy Fork is available in English.

議論 » 開発

How to identify the script which make an error popup?

§
投稿日: 2021/01/31

I have a script (in my many userscripts installed...) which produce an error popup:
Error JavaScript application:
"exception: TypeError: document.getElementById(...) is null"

I can't found it simply:
- Disable one by one is not efficient or survey the browser console because,
It open this popup one time by day (like it search an update...)
- I have open some scripts code, to see if i can find some related to alert(),
but without result...

I use WWaterfox Classic and Gersemonkey 3.17 / Tampermonkey

§
投稿日: 2021/01/31

Here the popup

§
投稿日: 2021/01/31
編集日: 2021/01/31

Disabling one by one is the most efficient way in this case, though you will take like 1 month to figure out which script is showing this alert...

You can also try to paste and search in every single script codes this "document.getElementById(", then paste that with the element id on the page this alert is shown and if you get the null message on the console it means that that document.getElementById("ElementName") is causing the error

Usually userscripts doesn't shown an alert box with errors, this is usually only displayed in the console, then it's easy to figure out which script is causing the error, but since this is an alert box showing an error I don't think that this method will work.

You can also try to check all of your scripts to see which one of them have codes to display an personalized alert box with that 2 symbols. I don't think that this box is just an alert(), but I'm not sure how the default alert() box looks like on firefox anyways...

§
投稿日: 2021/01/31

Thanks!
As i said, i do a search with "alert".
I do a search with "TypeError" in some scripts active:
Same no result

I think make a search about "document.getElementById" sould not efficient too:
It's very common in script and i am not coder to understand if there is an error in the execution.

In an other hand, maybe it's an addon alert...
:-)

§
投稿日: 2021/01/31

If I were you I would do this:

  1. Find all scripts that contains "alert" and "document.getElementById"
  2. Code analysis or disabling one by one

Also, I have noticed a caption "exception" (screenshot below) that added either by the script, either by a browser. If it is added by the script, that could simplify your search a lot. Send to your browser console alert(new TypeError(123)). If the alert would not has caption "exception", it means you could search through the scripts that you get from the step 1 with phrase "exception" too.

§
投稿日: 2021/02/01

Hmmm... thanks for your suggestions.

Since a long time i try to caught this popup.
The console option should be great but as i said this alter goes 3 time by day.
And as i remember, when i trying to open the console when i see this damn popup,
i can't open it before closing the popup.

But i am not coder...
;-)

PS:
I find a script with:

function reportMessage(msg) {
console.log(msg);
}

function reportWarning(msg) {
console.warn(msg);
}

function reportError(msg) {
console.error(msg);
}

3 time, like exactly the number of time it open the popup...
I disble these line by /* */ :
I cross my finger.
Result in 1 or 2 adys.

§
投稿日: 2021/02/01

That is not you are looking for.

And you don't get my advice, I think. Can you just share your scripts? You are using greasemonkey, right? Here is described how to do this, up to step 3.

§
投稿日: 2021/02/01

Konk:
Ho yes, i take your advise in consideration:
You helped me to fix the Citrus script!

I make your test "alert(new TypeError(123))" in the console:
no "exception" in the popup

I know already that the error mention is always:
"exception: TypeError: document.getElementById(...) is null"

So that "exception" signify it's a script problem?

§
投稿日: 2021/02/01

I try to send you my scripts...
But greasemonkey don't like ZIP files...
I make a test by modifing the zip extention gif.
noway.
Any other solution?

§
投稿日: 2021/02/01

Exception means that the script is showing the text and contains this text in the codes,search in the codes for the exception text....

Gif and zip files has nothing to do with each other....

Then send us prints and or the name of all of the scripts you use...

§
投稿日: 2021/02/01

Btw anything that starts with console. means that it's and invisible message,not and alert)

§
投稿日: 2021/02/01

*unless it's like console alert()

§
投稿日: 2021/02/01
編集日: 2021/02/01

So that "exception" signify it's a script problem?

It is not a problem. It is a custom text that added by the script author that makes easier to find the script.

I try to send you my scripts... But greasemonkey don't like ZIP files...

You can use any file share service. https://dropmefiles.com/

§
投稿日: 2021/02/01

Konf:
i testd your service:
https://dropmefiles.com/uPxNI

It is working ?

§
投稿日: 2021/02/01

No, the only user script on that zip file is Flickr_-_AUTO_ShowAllGroups_(Photo_Page)_v2.user.js this doesn't help

§
投稿日: 2021/02/01

It seems that you could erase this line
catch (e) {
alert("exception: " + e);
}

and you should probably erase this line too
catch (e) {
callback({ threadId: threadId, success: false, message: 'Exception: ' + e });
}

These seems to be the buggy scripts
Flickr Commented On (HTTPS) - v.2.29 - Tweak 2020
Flickr - Number of Favs on Photostream - OK

§
投稿日: 2021/02/01

*I've converted all the .js files to .txt files and joined then into 1 single .txt file to make it easier to ctrl+f
https://dropmefiles.com/VsYfg

§
投稿日: 2021/02/01

I test that !
Good job....

§
投稿日: 2021/02/01

About "Flickr - Number of Favs on Photostream - OK "

If i comment this code to disable it: the script stop working:
//PB POP ERROR TEST by Hacker09

/*
catch (e) {
callback({ threadId: threadId, success: false, message: 'Exception: ' + e });
}
}
*/

§
投稿日: 2021/02/01

Same if i do:

//PB POP ERROR TEST by Hacker09

/*
catch (e) {
callback({ threadId: threadId, success: false, message: 'Exception: ' + e });
}
*/

§
投稿日: 2021/02/01

About the GM:
Flickr Commented On (HTTPS) - v.2.29 - Tweak 2020

It stop working too if i do:

// PB POP ERROR TEST by Hacker09
/*
} catch (e) {
alert("exception: " + e);
}
*/
})();

§
投稿日: 2021/02/01

They are both the same thing. Try erasing this
catch (e) {
alert("exception: " + e);
}

If nothing I said works, then I don't know what else could be done...

§
投稿日: 2021/02/01

when i erase these lines, the script stop working...
Maybe it possible to keep them and change the "alert("exception: " + e);" which open a popup,
for only an alert into the console console?

So , i tested, and the script work :
// PB POP ERROR TEST by Hacker09

} catch (e) {
// alert("exception: " + e);
alert();
}


But i don't know if it is good for the popup problem...

§
投稿日: 2021/02/01

I do the same thing for GM ""Flickr - Number of Favs on Photostream - OK ""
//PB POP ERROR TEST by Hacker09
catch (e) {
// callback({ threadId: threadId, success: false, message: 'Exception: ' + e });
callback({ threadId: threadId, success: false, message: 'Test: ' + e });
}


Script work, but like for my other bad trick, i don't know id it solve the popup...

§
投稿日: 2021/02/01

That should be good for the popup problem... Now just wait...

§
投稿日: 2021/02/02

hacker09, "try" construction will never work without "catch" part

§
投稿日: 2021/02/02
編集日: 2021/02/02

decembre, all you need to do is to remove a one single string from the screenshot. That is the topic problem fix. Still, the popup means that script is broken to some extent.

§
投稿日: 2021/02/02

hacker09, "try" construction will never work without "catch" part



Yeah I was thinking that this is the case. Thanks

§
投稿日: 2021/02/02

konf and hacker09, Thanks to you!

These scripts work with your suggestions (that's very old scripts unmaintained, but useful for me).
Now wait and see for the popup thing;

§
投稿日: 2021/02/02

You are welcome.

Unfortunately we are the "only 3" active users on greasyfork anyways...

§
投稿日: 2021/02/02

i hope not!
:-)

§
投稿日: 2021/02/03

Good new:
No popup error since your last corrections.

Re thanks you dear, "active' users!

返信を投稿

返信を投稿するにはログインしてください。