I am trying to write a userscript that will remove the effects of onselectstart
from an id on a page.
So far I am assuming that I can rebind the original function using something like this:
document.getElementById('nodrag').onselectstart = function() { /* code original action */ };
Any ideas would be appreciated.
Advertisement
Answer
Looks like I managed to work out the answer. Thank you LightStyle for giving me the hints.
So I create an script tag with document.getElementById('nodrag').onselectstart = function() { };
inside it and append this to the body.
// Create the script to remove the nodrag from chrome var script = document.createElement('script'); script.type='text/javascript'; script.innerHTML = "document.getElementById('nodrag').onselectstart = function() { };"; var body = document.getElementsByTagName('body')[0]; body.appendChild(script);
This might not work in traditional contexts however works a charm on a userscript. Here is the final script: