Re-enabling the browser right click

Wed 19th Oct 16

I've spent the day testing an app which disables the right click context menu, this makes testing tricky so I found the following one liner which I could drop into the browser console to re-enable it for me:

var ele=document.getElementsByTagName("*");for (var id=0;id<ele.length;++id) {ele[id].oncontextmenu=null;};document.oncontextmenu=null;window.oncontextmenu=null;

To use this in Chrome or Firefox, simply hit F12 to bring up the built in console and paste it in.

Or, as just suggested by Jason, you can put this into a bookmark like this:

javascript:(function(){var ele=document.getElementsByTagName("*");for (var id=0;id<ele.length;++id) {ele[id].oncontextmenu=null;};document.oncontextmenu=null;window.oncontextmenu=null;})();

I also found that adding the following entry to the Burp 'Match and Replace' feature would stop the code that disabled it before it even reached the browser:

Burp 'Match and Replace' setting

This may not work in every app and will probably break apps which disable the menu in some areas but add custom menus in others, but it worked for me and so I'm putting it here as a reference for when I come back to this app. It also won't work for sites which trap the onmousedown event, for those, just swap this event with oncontextmenu and run it again.