Here is my very simple code:
document.addEventListener("DOMContentLoaded", function() {
console.log('Your document is ready!');
});
I paste it in the developer console of the browser. However, it does not log anything. Could anyone please help me find out why is it happening?
All I get after executing the script is undefined
. The same code works if I remove the loading wrapper.
console.log('Your document is ready!');
I want to run the script in Tampermonkey. Here is the original script:
document.addEventListener("DOMContentLoaded", function(){
document.querySelector("._3xiuDJ ._52MoHd").innerHTML = 'Test';
});
With the DOM load event, it does not do anything. Without the DOM load event, I get the following error:
document.querySelector(...) is null
If I directly paste it in the developer console like this,
document.querySelector("._3xiuDJ ._52MoHd").innerHTML = 'Test';
It works perfectly.
If I place it in the Tampermonkey script. It gives me the above null error. If I place it inside the wrapper in the Tampermonkey script, it does not do anything.
Thanks.