1

I have a script that I want to run on EVERY page. To do it has been quite easy I simply set @include * and its done. It shows up on every page, activated by a hotkey combination I have assigned to it inside the code. It works as expected and without issues.

HOWEVER, I would like this to also be available on a blank tab as well. If you have a page with actual content (document assignment if you will) it works fine, I guess it has something to inject the script into and run with, I get that. I am wondering and hoping if there is a way to also have the script hook the blank tab page as well.

I have done considerable research on this to no avail, I am hoping some of my friends here with more extensive exposure to JS and perhaps experience gained in the trenches with regards to this matter might have a solution to offer. I would greatly appreciate it.

GµårÐïåñ
  • 2,846
  • 5
  • 31
  • 35

1 Answers1

2

See the docs at "Include and exclude rules, Extra schemes". for a script to run on blank tabs, you must now explicitly set @include about:blank.

For example:

// ==UserScript==
// @name        _Very noisy script
// @include     about:blank
// @include     *
// ==/UserScript==

alert ("Fire on blank");

However, Firefox now uses about:newtab by default, and Greasemonkey currently doesn't consider about:newtab to be "Greaseable". (It should though, and I'll look into getting a pull-request accepted for this.)

So, to get scripts firing on blank tabs, you currently must set those blank tabs back to using about:blank.
Do that by opening about:config and setting browser.newtab.url to about:blank.

Brock Adams
  • 90,639
  • 22
  • 233
  • 295
  • Its good to hear from you my friend. I actually did come across that in my research, but thank you for listing it. Unfortunately it doesn't show up unless you specifically open `about:blank` tab but it seems that nowadays they all use `about:newtab` which doesn't work as an include it seems. Any ideas? – GµårÐïåñ Aug 23 '13 at 06:34
  • 1
    BTW, I didn't notice but its not annoying, its really functional :) It allows me to use a key combination to pop up a box that I can put what I am looking for in it and it will process and produce in a new tab for me. I am a keyboard guy and hate point and click, so this allows me to stay in my comfort zone by mimicking a keyboard movements. – GµårÐïåñ Aug 23 '13 at 06:44
  • 1
    We'll have to open a bug or feature request for `about:newtab`. I'd forgot about that change. Meanwhile open `about:config` and set `browser.newtab.url` to `about:blank`. This will stop Firefox's annoying new page and allow the script to work. – Brock Adams Aug 23 '13 at 08:06
  • Agreed, they need to now account for this new change. For Firefox yes, changing the setting would do the job but its not a cross browser solution, since you can't do it in say Chrome, where this script works fine except on newtab or even blank :( and the script wouldn't work straight out of the box. Oh well I know the limitations for the moment and I will live within them but wish they would standardize. – GµårÐïåñ Aug 23 '13 at 15:05
  • This question is not tagged for Chrome or cross-browser! (Nor did you indicate that until just now) The question is answered as posed. [Greasemonkey == Firefox](http://stackoverflow.com/tags/greasemonkey/info), and this is a completely different problem on Chrome. – Brock Adams Aug 23 '13 at 22:22
  • Ok my bad, but I just wanted the script to work, my primary dev environment is Firefox, just that since Chrome has inherent capability to handle GM scripts and additionally there is TamperMonkey that handles the shortcomings of Chrome's inherent conversion of GM scripts (for example lack of certain API functions) I have been able to successfully run ANY script that I have developed for Firefox on GM to run on Chrome using TM without issue. So that's why I didn't bring it up, the compatibility with other browser was just secondary and a bonus for a more robust code, that's all. – GµårÐïåñ Aug 24 '13 at 03:01
  • Just to add another note, I contacted the GM team and asked them to expand the support for `about:blank` to also extend to `about:newtab` either as a function overloading or a new API or explicit item, whatever they see fit and works best. If you are interested here is the issue and arantius is looking into it (https://github.com/greasemonkey/greasemonkey/issues/1791) – GµårÐïåñ Aug 24 '13 at 03:07