I need to remove the following event listeners with my Chrome extension, after the page loaded.
Page content:
<input type="password" size="15" value="" autocomplete="off"
onkeyup="javascript:vaciar(this)"
onkeypress="javascript:vaciar(this)"
onkeydown="javascript:vaciar(this)" name="password"
id="contrasena" />
The code in my content script is:
var password_field = document.getElementById("contrasena");
password_field.removeAttribute("onkeypress");
password_field.removeAttribute("onkeydown");
password_field.removeAttribute("onkeyup");
password_field.onkeypress = null;
password_field.onkeydown = null;
password_field.onkeyup = null;
For some reason, the event listeners keep active, but when I copy and execute the code in the console it works.