Question: I want to write a bookmarklet that will modify any webpage so that when the JavaScript code on that page does something like `document.location = 'http://site.tld'` or `document.location.href = 'http://site.tld'` the page will open a new tab or window instead of changing location; same as if code was `window.open('http://site.tld')`;

Can I modify the prototype somehow to achieve this goal? (I use this word carelessly because although I've read about modifying prototypes a few times, I've never actually done it.) Or is there some other way?

Answer: 
You could only do something with the prototype if it were a function call rather than an assignment. For example in the case of document.write 

```
document.write = function(txt) {
   alert("txt");
};

document.write("test");   

```
FWIW: This works on the latest firefox to search for the selected text in a new tab:

javascript:Qr=document.getSelection();if(!Qr){void(Qr=prompt('Keywords...',''))};if(Qr)window.open("<http://google.com/search?query=>"+escape(Qr));void(0)