How to stifle messages like "A Parser-blocking, cross-origin script..."



  • I have a basic PyQt5 app that uses QWebEnginePage to display selected web URLs, which often have advertisements on them. Some of these ads cause QWebEngine to log console messages of the form,

    A Parser-blocking, cross-origin script, http://ads.thehiveworks.com/delivery/spc.php?zones=245|246|387&source=&r=29650133&charset=UTF-8&loc=http%3A//sssscomic.com/comic.php, is invoked via document.write. This may be blocked by the browser if the device has poor network connectivity. See https://www.chromestatus.com/feature/5718547946799104 for more details.

    (n.b. the chromestatus url explains how the designer of the loaded page is doing things wrong -- but I have no control over that!)

    These console messages are annoying and unhelpful to the user and I want to make them stop. I tried making a custom QWebEnginePage class with an override of javaScriptConsoleMessage(). This revealed that although the messages are delivered to that method, they are ALSO printed to the real console first before the method is called!

    I can't find how to control the Qt Logging framework to make it ignore javaScript log messages. Any suggestions welcome!



  • As a work-around (not a solution) the user is doing the following:

    python the_qt_script.py > /dev/null 2>&1
    

    It is necessary to use "2>&1" to force stderr into /dev/null before these many annoying messages disappear. Of course, it is possible that meaningful messages are also being discarded! So, control of the Java Console output is still needed.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.