How to run Javascript code on any website?

You don't need an extension for that. Use the console.

To open the Console tab, do one of the following:

  • Use the keyboard shortcut Command-Option-J (Mac) or Control-Shift-J (Windows/Linux).

  • Select View > Developer > JavaScript Console.

Now you can execute any Javascript you want. Variables and functions that are defined in the global scope of the current document can also be used.

For example, if the current site has jQuery included, you can send JSON to a remote script:

$.post( "http://example.com/test.php", { foo: "bar" } );

Accepted answer works, but here is another method if you dont have access to the javascript console.

The javascript protocol allows you to run javascript on any website just by entering it into the url bar in this format: javascript:alert('Hello World');