AdamH
AdamH

Reputation: 141

Is there any way to run a userscript without using Greasemonkey or Tampermonkey?

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?

Upvotes: 3

Views: 11168

Answers (3)

ccpizza
ccpizza

Reputation: 31686

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.

Upvotes: 1

jongo45
jongo45

Reputation: 3090

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.

Upvotes: 2

Deadron
Deadron

Reputation: 5289

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.

Upvotes: 2

Related Questions