3

Is there any way to run a user script without running it through Greasemonkey/Tampermonkey?

I know its a simple question but I can't find any information on this...or if it's even possible.

Can the user script be edited so it doesn't rely on Greasemonkey?

Brock Adams
  • 90,639
  • 22
  • 233
  • 295
AdamH
  • 141
  • 5
  • 16
  • 1
    Are you asking if you can run arbitrary javascript on a page on demand or are you asking if there is a way to always run arbitrary javascript when a page loads? – Deadron Oct 23 '14 at 16:28
  • 1
    @Deadron on page load thanks :) – AdamH Oct 23 '14 at 16:29

3 Answers3

2

It's up to the browser you are using to enable support for running arbitrary javascript on page load.

Chrome has limited userscript support, but is nowhere near as easy or powerful as Tampermonkey.
Tampermonkey and Greasemonkey (and other browser extensions) were created to address the userscript need.

You do have options for running javascript after a page has loaded though. You can use the developer tools console or you can create a Bookmarklet.

Brock Adams
  • 90,639
  • 22
  • 233
  • 295
Deadron
  • 5,135
  • 1
  • 16
  • 27
2

On firefox:

You can use the Scriptish addon (an alternative to greasemonkey for automatically running userscripts).

There is the Developer Scratchpad for editing, saving, loading and running scripts (and userscripts) manually. Also, can be applied on either the current document or browser chrome. Accessed via shift-F4 or Developer > Scratchpad.

And then there is also GCLI (Graphical Command Line Interpreter) which you can write routines for via a mozcmd file and is run manually. You'll need to modify the userscript a bit to access window, document objects. Accessed via shift-F2 or Developer > Developer Toolbar.

This one is a bit more involved, but if you want to go the addon route, you can write an addon using the Addon SDK, and use the page-mod API which injects a userscript into a page automatically.

jongo45
  • 3,020
  • 2
  • 16
  • 12
  • after trying to use use Greasemonkey to run jquery after page load, where angular js is used, i ended up being here. – Ahmad Ismail Jun 20 '16 at 19:10
0

In Google Chrome or Firefox you can open the DevTools (e.g. by right-clicking the page and selecting Inspect) and then paste the code in the Console tab and press Enter to run it.

In Google Chrome DevTools you can also create a js snippet and run it on demand whenever you need it.

You can also use Chrome DevTools Snippets:

  1. Right-click anywhere on the page and select Inspect.
  2. Select the Sources tab — you will see a number of subtabs: Page, Filesystem, Override, Content scripts and finally Snippets (you might need to click >> in order to see it).

Click the plus button to add the js code, and use right-click > Run to execute the code.

NOTE: If the original script uses extra js libraries (jquery, etc) and the libs are not already preloaded on the page, then you'll need to load them yourself (see this).

Unlike the code you run from the Console, you can set breakpoints in your JS snippets.

ccpizza
  • 28,968
  • 18
  • 162
  • 169