2024-06-07:
=======================================================================
VM62:3 [Violation] Avoid using document.write().
https://developers.google.com/web/updates/2016/08/removing-document-write
-----------------------------------------------------------------------
You get this error message on broser's console when you reload
the page that uses HObfus.
This is a Chrome specific issue. It only appears on Chrome.
It won't show up in FireFox and Edge.
=======================================================================
=======================================================================
The point is why this message appeares ***ON RELOADING ONLY***
(It doesn't appear at the first time.)
=======================================================================
=======================================================================
Solution #1
-----------------------------------------------------------------------
It is obvious that it has something to do with document.write()
used in HObfus. Here is an alternative way to inject code to the DOM.
-----------------------------------------------------------------------
https://stackoverflow.com/questions/73533135/chrome-violation-when-using-document-write-with-generated-iframe-source-altern
-----------------------------------------------------------------------
[Use DOMParser]
const docNew = new DOMParser().parseFromString(html, 'text/html');
docOld.insertBefore(docNew.doctype, docOld.firstChild);
docOld.replaceChild(docNew.documentElement, docOld.documentElement);
=======================================================================
=======================================================================
Solution #2
-----------------------------------------------------------------------
Modify the console object
-----------------------------------------------------------------------
Can I selectively hide only certain types of console errors
https://www.perplexity.ai/
-----------------------------------------------------------------------
const originalWarn = console.warn;
console.warn = (message, ...args) => {
if (message.includes('Error message to suppress')) {
// Don't log this error
return;
}
// Log other warnings
originalWarn(message, ...args);
}
=======================================================================
=======================================================================
Solution #3
-----------------------------------------------------------------------
ChatGPT
-----------------------------------------------------------------------
Suppress Console Warnings (Not Recommended)
-----------------------------------------------------------------------
console.warn = function() {};
=======================================================================
=======================================================================
Solution #4
-----------------------------------------------------------------------
ChatGPT
-----------------------------------------------------------------------
Use createContextualFragment(content);
-----------------------------------------------------------------------
-----------------------------------------------------------------------
[CRITICAL ISSUE!!!]
createContextualFragment does not execute