User talk:Joeytwiddle: Difference between revisions

From GreaseSpot Wiki
Jump to navigationJump to search
m wouldn't want people thinking these work yet!
Line 3: Line 3:
It could be useful to have an extra meta tag:
It could be useful to have an extra meta tag:


{{Core samp |1=<pre style="border: none; margin: inherit;">// @loadlib    script_name</pre>}}
{{Bad samp |1=<pre style="border: none; margin: inherit;">// @loadlib    script_name</pre>}}


The loadlib meta would cause Greasemonkey to load the specified script from the user's gm_scripts/ folder before running the userscript which contained the meta.
The loadlib meta would cause Greasemonkey to load the specified script from the user's gm_scripts/ folder before running the userscript which contained the meta.
Line 27: Line 27:
It is common that you want your userscript to add some floating menus or windows on top of the page.  Unfortunately these will often inherit CSS rules from the page, and your added elements can end up with strange colours and alignment.  It would be handy to break out of page style settings and create elements using a default empty stylesheet.  How might this be possible?  Can we literally move to a fresh CSS namespace?  Or do we need something like this?
It is common that you want your userscript to add some floating menus or windows on top of the page.  Unfortunately these will often inherit CSS rules from the page, and your added elements can end up with strange colours and alignment.  It would be handy to break out of page style settings and create elements using a default empty stylesheet.  How might this be possible?  Can we literally move to a fresh CSS namespace?  Or do we need something like this?


{{Core samp |1=<pre style="border: none; margin: inherit;">GM_clearStyle(node_element,bool_clearChildren);</pre>}}
{{Bad samp |1=<pre style="border: none; margin: inherit;">GM_clearStyle(node_element,bool_clearChildren);</pre>}}


I often want to visit the homepage of a script I have installed, but the author didn't include it.  I would like Greasemonkey to make a record of the update URL and the homepage of a script when I install it.  We could insert the meta tags if they were not included by the author, or inaccurate.  There are update scripts which try to track scripts, but shouldn't it be supported?
I often want to visit the homepage of a script I have installed, but the author didn't include it.  I would like Greasemonkey to make a record of the update URL and the homepage of a script when I install it.  We could insert the meta tags if they were not included by the author, or inaccurate.  There are update scripts which try to track scripts, but shouldn't it be supported?


Finally a thought on logging and @namespace.  The only standard I have really seen @namespace used for is to provide the homepage of the script or the author in @namespace.  Should this be officially declared as the intention of @namespace?  And since these URLs are often long, does it really make sense to make them part of the headers of log messages?  Wouldn't just the name of the script be more appropriate when reading the log?
Finally a thought on logging and @namespace.  The only standard I have really seen @namespace used for is to provide the homepage of the script or the author in @namespace.  Should this be officially declared as the intention of @namespace?  And since these URLs are often long, does it really make sense to make them part of the headers of log messages?  Wouldn't just the name of the script be more appropriate when reading the log?

Revision as of 06:42, 10 June 2009

Suggestions

It could be useful to have an extra meta tag:

Template:Bad samp

The loadlib meta would cause Greasemonkey to load the specified script from the user's gm_scripts/ folder before running the userscript which contained the meta.

This would allow us to define a library script of common functions which we can re-use in any of our userscripts, simply by adding the meta. These library scripts are always loaded from a trusted source, they are local userscripts which do nothing when run alone.

Sounds like a good start to a feature request in case the sandbox isn't ever expanded... you may wish to enter an enhancement ticket at http://greasemonkey.devjavu.com/newticket with this instead of the wiki talk pages. It will get the proper attention there. Marti 04:46, 7 June 2009 (EDT)

Thanks Marti, I see that is where the development discussion is. The greasemonkey-dev mailing list looks a bit overwhelmed by what look to me like user questions!

I'm actually quite happy that Greasemonkey has kept its API small, this can accommodate wider compatibility. I think any additions to the API should be discussed over time by developers and users. I was wondering whether the developers were intending to extend Greasemonkey in the future, or have decided to keep it small and tidy, and leave the addition of features (aka bloat) to other projects.

Regarding LibraryUserscripts, I should still think about other ways to do it. I saw there is a Google project that offers some extra functionality for Greasemonkey scripting of Google Groups data (or was it Google Reader?). I don't know how this is delivered, maybe it is an object they supply in the DOM for all browsers.

It just occurred to me that one existing way of making a library userscript would be to have it create an Object full of useful functions, and embed it in the DOM. Any userscripts which execute later could reference the object to make use of those functions. Unfortunately this raises security issues since untrusted scripts can access that globally visible object too. (Maybe we can force our library to drop GM internals from our scope, using fn.toString() for example.) We would somehow need to ensure the library scripts run first, and that they run on all pages where one of their dependent scripts will run.

-

There are other problems I would be interested in solving.

ClearingStyle

It is common that you want your userscript to add some floating menus or windows on top of the page. Unfortunately these will often inherit CSS rules from the page, and your added elements can end up with strange colours and alignment. It would be handy to break out of page style settings and create elements using a default empty stylesheet. How might this be possible? Can we literally move to a fresh CSS namespace? Or do we need something like this?

Template:Bad samp

I often want to visit the homepage of a script I have installed, but the author didn't include it. I would like Greasemonkey to make a record of the update URL and the homepage of a script when I install it. We could insert the meta tags if they were not included by the author, or inaccurate. There are update scripts which try to track scripts, but shouldn't it be supported?

Finally a thought on logging and @namespace. The only standard I have really seen @namespace used for is to provide the homepage of the script or the author in @namespace. Should this be officially declared as the intention of @namespace? And since these URLs are often long, does it really make sense to make them part of the headers of log messages? Wouldn't just the name of the script be more appropriate when reading the log?